Jump to content
php.lv forumi

javascript iframe


Devils666

Recommended Posts

mana problēma tāda, ka javascript īpaši nesaprotu, bet man vaig izveidot tādu kodu:

 

ja iframe links tiek atrasts un lapa ir online,

tad parādīt iframe, ja nē, tad parādīt tikai to ka iframe netika atrasta

 

ka kaut ko tadu varētu dabūt gatavu?

Link to comment
Share on other sites

nu vienkārši, vai viņa atbil vai nē

 

ar php tas būtu piem šādi:

<?
function Visit($url)

{

$agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";$ch=curl_init();

curl_setopt ($ch, CURLOPT_URL,$url );

curl_setopt($ch, CURLOPT_USERAGENT, $agent);

curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt ($ch,CURLOPT_VERBOSE,false);

curl_setopt($ch, CURLOPT_TIMEOUT, 5);

$page=curl_exec($ch);

//echo curl_error($ch);

$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

curl_close($ch);

if($httpcode>=200 && $httpcode<300) return true;

else return false;

}

if(Visit("http://www.domain.com"))

          echo "Website OK"."n";

     /*if site down*/

    else

         echo "Website DOWN";
?>

Edited by Devils666
Link to comment
Share on other sites

Šis nav testēts, bet moš strādā :) diezgan haxorīgs variants:

 

<img src="http://hosts.com/bildiite.jpg" onerror="hostsOffline()" onload="hostsOnline()" style="display:none;"/>

 

...protams, ja tas ir webserveris, un tur eksistē kāda bilde...

Edited by briedis
Link to comment
Share on other sites

hmm, bet kā tas domāts? es to ko tu man iedevu isti nesaprotu :(

un man jau to uz iframe vajadzēja...

 

Nu izveido attiecīgās funkcijas, kas dinamiski parāda/paslēpj ifreimu, uzstādam tam vajadzīgo atribūta src vērtību...

Link to comment
Share on other sites

<img src="http://miljons.com/img/logolv.gif" onerror="hostsOffline()" onload="hostsOnline()" style="display:none;"/>

<iframe src='http://miljons.com' width=300 height=300 border=0 frameborder=0 scrolling=no></iframe>

bet priekškam tā bilde isti domata? kaut ko nesaprotu...

Link to comment
Share on other sites

<img src="http://miljons.com/img/logolv.gif" onerror="hostsOffline()" onload="hostsOnline()" style="display:none;"/>

<iframe src='http://miljons.com' width=300 height=300 border=0 frameborder=0 scrolling=no></iframe>

bet priekškam tā bilde isti domata? kaut ko nesaprotu...

 

"sākuma, vismaz vai kāds var pateikt, vai ar javascriptu var pārbaudīt,

piemēram - www.uberkrutais.lv, vai lapa ir online vai nav "

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...