954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Top page Banner script

Hello, I need a script that will be added after

b0tz
Newbie Poster
15 posts since Jul 2008
Reputation Points: 10
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?

MattTheHat
Newbie Poster
10 posts since May 2009
Reputation Points: 10
Solved Threads: 0
 

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:

<?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>
essential
Posting Shark
974 posts since Aug 2008
Reputation Points: 114
Solved Threads: 138
 

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 tag and display only one time ?

By the way, I can only put the JS cod AFTER

b0tz
Newbie Poster
15 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

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:

<!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>
essential
Posting Shark
974 posts since Aug 2008
Reputation Points: 114
Solved Threads: 138
 
isObject.appendChild( document.createTextNode("The banner script is HERE."));

I don't think that this will help me add html code.

<!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>

The output is showing only the text that I put there.

Thanks

b0tz
Newbie Poster
15 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

Sorry i thought that it was just a simple text insertion. Here's modified version and configured according to your needs:

<!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>
essential
Posting Shark
974 posts since Aug 2008
Reputation Points: 114
Solved Threads: 138
 

wow, you even put my iframe codes. Thank you. I will test them right now and see if are working.

Thank you very much.

I will reply here when all is working. It should take around 20 minutes to update to server.

Thanks again.

b0tz
Newbie Poster
15 posts since Jul 2008
Reputation Points: 10
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.

Attachments index.txt (11.91KB)
b0tz
Newbie Poster
15 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

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:

<!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>
essential
Posting Shark
974 posts since Aug 2008
Reputation Points: 114
Solved Threads: 138
 

Hello,
On localhost is working, I will add it to the server. It will take about 15-30 minutes to update all the accounts.
I will keep you update, for now, thank you for your hard work.

b0tz
Newbie Poster
15 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

Thank you , the script is working .
+rep

b0tz
Newbie Poster
15 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You