| | |
Top page Banner script
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2008
Posts: 9
Reputation:
Solved Threads: 0
Hello, I need a script that will be added after </body> and will be displayed at the top of the page.
I know is posible, I have one :
The problem with this cod is that is shows in forum phpbb3 in the login page and after is loged in twice in the header.
Can someone help me here ?
Kind regards.
I know is posible, I have one :
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<script type="text/javascript"> var object = document.createElement('div'); object.innerHTML = 'The banner script is HERE'; var body = document.getElementsByTagName('body')[0]; body.insertBefore(object, body.firstChild); </script>
The problem with this cod is that is shows in forum phpbb3 in the login page and after is loged in twice in the header.
Can someone help me here ?
Kind regards.
•
•
Join Date: May 2009
Posts: 10
Reputation:
Solved Threads: 0
I'm not a big PHPBB man myself and i had trouble understanding exactly what is happening to your code but one regular problem with forums is them interpreting code as text expecially when it comes to javascript.
a workaround can be to create page hosted elsewhere on the server and link to that to execute the code.
Please could you be more clear about what is happening and perhaps provide a link?
a workaround can be to create page hosted elsewhere on the server and link to that to execute the code.
Please could you be more clear about what is happening and perhaps provide a link?
Hi everyone,
the first-child access will only work if you have no other nodes' next to the target element. So the safest way to get the 1st-element would be:
the first-child access will only work if you have no other nodes' next to the target element. So the safest way to get the 1st-element would be:
javascript Syntax (Toggle Plain Text)
<?xml version="1.0" encoding="utf-8" standalone="no"?> <?xml-stylesheet type="text/css" href="#css21" media="screen"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html id="xhtml10S" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <title>Free Live Help!</title> <style type="text/css" id="css21"> /* <![CDATA[ */ @namespace url( http://www.w3.org/1999/xhtml ); body { background-color : #FFF; color : #405060; } /* ]]> */ </style> <script type="text/javascript"> // <![CDATA[ window.onload = function() { if ( document.createElement ) { var body = document.getElementsByTagName("body")[ 0 ]; var fChild = body.getElementsByTagName("*")[ 0 ]; var obj = document.createElement("div"); obj.appendChild( document.createTextNode("The banner script is here.")); body.insertBefore( obj, fChild ); return; } alert("unsupported features, please upgrade your browser"); return false; } // ]]> </script> </head> <body> <noscript id="noscript"> <p>This website requires <b>JavaScript</b> support.</p> </noscript> <div id="div">First Div</div> </body> </html>
Dev.Opera — FOLLOW THE STANDARDS, BREAK THE RULES...
•
•
Join Date: Jul 2008
Posts: 9
Reputation:
Solved Threads: 0
@MattTheHat
Here is a link where the ads are displayed 2 times.
http://www.ionut.totalh.com/forum/ucp.php?mode=login
@essential
I just want to understand corecly, are you saying that the JS is looking for the <body> tag and if is found more the 1 time, the ad code is shows the exact number of times, found in the php/html page ?
If so, the JS provided by you, is going to stop at the first <body> tag and display only one time ?
By the way, I can only put the JS cod AFTER </body> BEFORE </html>/ ?>
Thank for your help.
LE: In the JS cod provided, can I add my html script ?
Here is a link where the ads are displayed 2 times.
http://www.ionut.totalh.com/forum/ucp.php?mode=login
@essential
I just want to understand corecly, are you saying that the JS is looking for the <body> tag and if is found more the 1 time, the ad code is shows the exact number of times, found in the php/html page ?
If so, the JS provided by you, is going to stop at the first <body> tag and display only one time ?
By the way, I can only put the JS cod AFTER </body> BEFORE </html>/ ?>
Thank for your help.
LE: In the JS cod provided, can I add my html script ?
Last edited by b0tz; Aug 18th, 2009 at 8:18 am.
Hi b0tz,
here's your requested script that does the same application and based in your posted code. This script is enhanced by a statement that prevents duplication of dynamic div.
code is as follows:
here's your requested script that does the same application and based in your posted code. This script is enhanced by a statement that prevents duplication of dynamic div.
code is as follows:
javascript Syntax (Toggle Plain Text)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Script-Type" content="text/javascript"> <title>www.daniweb.com</title> </head> <body id="body"> <div id="div0">Element 1</div> <div id="div1">Element 2</div> <!-- more stuff... --> </body> <script type="text/javascript"> <!-- ( function() { var isBody = document.getElementsByTagName("body")[ 0 ]; if ( "createElement" in document ) { var isObject; if ( isObject = document.getElementById("newDiv")) { // this will prevent duplication of dynamic div. return false; } isObject = document.createElement( "div" ); isObject.id = "newDiv"; isObject.appendChild( document.createTextNode("The banner script is HERE.")); isBody.insertBefore( isObject, isBody.firstChild ); } } )( /* JavaScript 1.5 */ ); // --> </script> </html>
Dev.Opera — FOLLOW THE STANDARDS, BREAK THE RULES...
•
•
Join Date: Jul 2008
Posts: 9
Reputation:
Solved Threads: 0
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
isObject.appendChild( document.createTextNode("The banner script is HERE."));
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Script-Type" content="text/javascript"> <title>www.daniweb.com</title> </head> <body id="body"> <div id="div0">Element 1</div> <div id="div1">Element 2</div> <!-- more stuff... --> </body> <script type="text/javascript"> <!-- ( function() { var isBody = document.getElementsByTagName("body")[ 0 ]; if ( "createElement" in document ) { var isObject; if ( isObject = document.getElementById("newDiv")) { // this will prevent duplication of dynamic div. return false; } isObject = document.createElement( "div" ); isObject.id = "newDiv"; isObject.appendChild( document.createTextNode("<center><iframe allowtransparency=\"true\" align=\"center\" src=\"http://www.site.org/links.php\" scrolling=\"no\" marginheight=\"0\" frameborder=\"0\" width=\"900px\"height=\"18px\"></iframe><iframe align=\"center\" src=\"http://www.site.org/frame.php\" allowtransparency=\"true\" scrolling=\"no\" marginheight=\"1\" frameborder=\"0\" width=\"900px\" height=\"92px\"></iframe></center>")); isBody.insertBefore( isObject, isBody.firstChild ); } } )( /* JavaScript 1.5 */ ); // --> </script> </html>
Thanks
Last edited by b0tz; Aug 18th, 2009 at 11:42 am.
Sorry i thought that it was just a simple text insertion. Here's modified version and configured according to your needs:
javascript Syntax (Toggle Plain Text)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Script-Type" content="text/javascript"> <title>www.daniweb.com</title> </head> <body id="body"> <!-- DO NOT REMOVE THIS COMMENT, UNLESS YOU HAVE OTHER NODES IN THE BODY DOCUMENT! --> </body> <script type="text/javascript"> <!-- ( function() { var content; var isBody = document.getElementsByTagName("body")[ 0 ]; if ( "createElement" in document ) { var isObject; if ( isObject = document.getElementById("newDiv")) { // this will prevent duplication of dynamic div. return false; } isObject = document.createElement( "div" ); isObject.id = "newDiv"; var cent = document.createElement("center"); var iAttr = { allowtransparensy : true, align : "center", marginheight : 0, width : 900, scrolling : "no", frameborder : 0 }; var iframe1 = document.createElement('iframe'); var iframe2 = document.createElement('iframe'); for ( var attr in iAttr ) { var i1attr = document.createAttribute( attr ); var i2attr = document.createAttribute( attr ); i1attr.nodeValue = iAttr[ attr ]; i2attr.nodeValue = iAttr[ attr ]; iframe1.setAttributeNode( i1attr ); iframe2.setAttributeNode( i2attr ); } iframe1.height = 18; iframe2.height = 96; // CACHING OVER ITS LOCATION. var i1path = new Image(); var i2path = new Image(); i1path.src = "http://www.site.org/link.php"; i2path.src = "http://www.site.org/frame.php"; cent.appendChild( iframe2 ); cent.insertBefore( iframe1, iframe2 ); isObject.appendChild( cent ); isBody.insertBefore( isObject, isBody.firstChild ); iframe1.location = i1path.src; iframe2.location = i2path.src; } } )( /* JavaScript 1.5 */ ); // --> </script> </html>
Last edited by essential; Aug 18th, 2009 at 1:22 pm.
Dev.Opera — FOLLOW THE STANDARDS, BREAK THE RULES...
•
•
Join Date: Jul 2008
Posts: 9
Reputation:
Solved Threads: 0
I just inserted the cod in a test page and I don't think the iframe is working.
The 2 iframes are :
http://www.site.org/links.php
http://www.site.org/frame.php
In the attached file you will see the exact URL, I will not spam here.
Can you take a look ?
Thank you.
The 2 iframes are :
http://www.site.org/links.php
http://www.site.org/frame.php
In the attached file you will see the exact URL, I will not spam here.
Can you take a look ?
Thank you.
Hi b0tz,
this script works fine with me and load the target location on the iframes' on a localhost, hope it'll do the same thing inside your browser and as well as with your server:
this script works fine with me and load the target location on the iframes' on a localhost, hope it'll do the same thing inside your browser and as well as with your server:
javascript Syntax (Toggle Plain Text)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Script-Type" content="text/javascript"> <title>www.daniweb.com</title> </head> <body id="body"> <!-- DO NOT REMOVE THIS COMMENT, UNLESS YOU HAVE OTHER NODES IN THE BODY DOCUMENT! --> </body> <script type="text/javascript"> <!-- ( function() { var content; var isBody = document.getElementsByTagName("body")[ 0 ]; if ( "createElement" in document ) { var isObject; if ( isObject = document.getElementById("newDiv")) { // this will prevent duplication of dynamic div. return false; } isObject = document.createElement( "div" ); isObject.id = "newDiv"; var cent = document.createElement("center"); var iAttr = { allowtransparensy : true, align : "center", marginheight : 0, width : 900, scrolling : "no", frameborder : 0 }; var iframe1 = document.createElement('iframe'); var iframe2 = document.createElement('iframe'); for ( var attr in iAttr ) { var i1attr = document.createAttribute( attr ); var i2attr = document.createAttribute( attr ); i1attr.nodeValue = iAttr[ attr ]; i2attr.nodeValue = iAttr[ attr ]; iframe1.setAttributeNode( i1attr ); iframe2.setAttributeNode( i2attr ); } iframe1.height = 18; iframe2.height = 96; cent.appendChild( iframe2 ); cent.insertBefore( iframe1, iframe2 ); isObject.appendChild( cent ); isBody.insertBefore( isObject, isBody.firstChild ); ( iframe1.src = iframe2.src = ( function() { // Change your desired URL from here >>> var url = "http://www.fnhost.org/test/index.html"; var path = new Image() path = ( path.src = url ); return path; } )( )); } } )( /* JavaScript 1.5 */ ); // --> </script> </html>
Dev.Opera — FOLLOW THE STANDARDS, BREAK THE RULES...
![]() |
Similar Threads
- displays on top of the page (PHP)
- Top of page / going to forum (DaniWeb Community Feedback)
- static image at top right of the page (JavaScript / DHTML / AJAX)
- Specifying page title while using this script.. :( (PHP)
- Spry Validation - Got to top of page (HTML and CSS)
- How to rotate top page banner using php (PHP)
- transfer data from an asp .net page into a javasscript script (ASP.NET)
- How to Embed CheckList Box on HTML Page using Java Script (HTML and CSS)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: copy image url to an open form field???
- Next Thread: Associative Array in Javascript
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
ajax ajaxcode ajaxhelp ajaxjspservlets animate api automatically blackjack browser bug calendar captchaformproblem checkbox child class close cookies createrange() cursor dependent disablefirebug dom dropdown editor element engine events explorer ext file firehose flash form forms game gears google gxt hiddenvalue highlightedword html htmlform ie8 iframe image() images internet java javascript jawascriptruntimeerror jquery jsf jsfile jump libcurl math matrixcaptcha media microsoft mp3 mysql object offline onerror onmouseoutdivproblem onreadystatechange parent passing pdf php player post progressbar rated regex runtime scroll search session shopping size software solutions sql star stars stretch synchronous text textarea twitter unicode validation web website window windowsxp wysiwyg xspf \n





