js скрипт(таймер)???
Как правильно написать 11.php что бы на сайте выполнялся js скрипт(таймер)???
Размещаем на сайте код: <script language="JavaScript" src="moisait/11.php?id=1"></script> 11.php <?php $id = intval($_GET[id]); ?> document.write('<script>function PopShow3() { setTimeout(function() {<iframe scrolling="no" width="50" height="50" src="moisait/22.php?id=<?php print "$id"; ?>" frameborder="0""></iframe>}, 30000)}document.onmouseover=PopShow3;<\/script>'); |
А какую роль тут играет php? И зачем скрипт выводить через document.write?
|
Цитата:
я в ифрейме использую id для идентификации src="moisait/22.php?id=<?php print "$id"; ?>" а как я js скрипт засуну в print""; ??? наверное можно как то) но там свой синтаксис Походу никак нельзя совместить js скрипт и <?php print "$id"; ?> ????? |
<iframe id="myframe" scrolling="no" width="50" height="50" data-src="moisait/22.php?id=5" frameborder="0" style="display:none"></iframe> <script> document.onmouseover = function() { document.onmouseover = null; setTimeout(function(){ var frame = document.getElementById('myframe'); frame.src = frame.getAttribute('data-src'); frame.style.display = ''; }, 3000); }; </script> |
А можно как то что бы внешний js брал свой id и вставлял в свой скрипт как php
Скрипт внешнего js( Можно как то в нем поменять php на js?) moisait//11.js?id=1 <?php $id = intval($_GET[id]); ?> function PopShow3() { setTimeout(function() { document.getElementById('popShow').innerHTML = '<iframe scrolling="no" width="50" height="50" src="moisait/22.php?id=<?php print "$id"; ?>" frameborder="0""></iframe>'; }, 30000) } document.onmouseover = PopShow3; |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251" /> <script src="moisait/11.php?id=1" type="text/javascript"></script> </head> <body> <div id="popShow"></div> </body> </html> 11.php: var popshow; document.onmouseover = function() { if(!popshow) popshow = setTimeout(function() { document.getElementById('popShow').innerHTML = '<iframe scrolling="no" width="50px" height="50px" src="moisait/22.php?id=<?=htmlspecialchars($_GET['id'])?>" frameborder="0"></iframe>'; }, 30000); } |
Не нужно писать 11.js?id=1 так как при разных параметрах id скрипт не будет кэшироваться, да и выдергивать id не очень удобно.
Лучше всего так: <script src="moisait//11.js" data-id="1"></script> 11.js: (function(){ var id = document.scripts[document.scripts.length - 1].getAttribute('data-id'); alert(id); })(); |
:thanks:
|
Часовой пояс GMT +3, время: 03:34. |