A little help needed (HTML and JAVA Script) ?

2 replies
Hi Warriors.

I need a little help in trying to get this page to work. I have tried and tried and have no idea what is wrong with it.

I basically want to put an iframe in my page that will rotate links. The problem I have is that

1- The iframe does not load.

2- The iframe loads but the rest of my page dissapears

3- The page loads but all of the images are mis placed

It is ver annoying for me, if some body could help it would be great.

also if its not a simple task I do not mind paying .

Regards

Steve

Here is the code I have

HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Changing Pages... Please Wait</title>
<script type="text/javascript">
var frames = Array('http://www.reddit.com/', 1,
'http://www.tesco.com/', 3,
'http://www.ask.com/', 2,
'http://www.dogpile.com/');
var i = 0, len = frames.length;
function ChangeSrc()
{
document.getElementById('frame').src = frames[i++];
if (i >= len) return; // no more changing
setTimeout('ChangeSrc()', (frames[i++]*1000));
}
window.onload = ChangeSrc;
</script>
</head>
<body>
<iframe src="" name="frame" id="frame" width="400" height="400"></iframe>
</body>
</html>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- Save for Web Slices (Untitled-2) -->
<table width="800" height="601" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
	<tr>
		<td colspan="3"><a href="http://twistedstats.com/Track/base2.php" target="_blank"><img src="http://www.warriorforum.com/images/index._01.jpg" alt="" width="792" height="112"></a></td>
		<td width="8" height="112" bgcolor="#000000">This is where I want the iframe</td>
	</tr>
	<tr>
		<td rowspan="2"><a href="http://twistedstats.com/Track/base2.php" target="_blank"><img src="http://www.warriorforum.com/images/index._03.jpg" alt="" width="180" height="434"></a></td>
		<td><a href="http://twistedstats.com/Track/base2.php" target="_blank"><img src="http://www.warriorforum.com/images/index._04.jpg" width="440" height="173" alt=""></a></td>
		<td colspan="2" rowspan="2" bgcolor="#000000"><a href="http://twistedstats.com/Track/base2.php" target="_blank"><img src="http://www.warriorforum.com/images/index._05.jpg" alt="" width="180" height="434"></a></td>
	</tr>
	<tr>
		<td><a href="http://twistedstats.com/Track/base2.php" target="_blank"><img src="http://www.warriorforum.com/images/index._06.jpg" alt="" width="440" height="261"></a></td>
	</tr>
	<tr>
		<td colspan="4" bgcolor="#000000"><a href="http://twistedstats.com/Track/base2.php" target="_blank"><img src="http://www.warriorforum.com/images/index._07.jpg" alt="" width="800" height="54"></a></td>
	</tr>
	<tr>
		<td>
			<img src="http://www.warriorforum.com/images/spacer.gif" width="180" height="1" alt=""></td>
		<td>
			<img src="http://www.warriorforum.com/images/spacer.gif" width="440" height="1" alt=""></td>
		<td>
			<img src="http://www.warriorforum.com/images/spacer.gif" width="172" height="1" alt=""></td>
		<td>
			<img src="http://www.warriorforum.com/images/spacer.gif" width="8" height="1" alt=""></td>
	</tr>
</table>
<!-- End Save for Web Slices -->
<script language=JavaScript>
<!--

//Disable right click script III- By Renigade (renigade@mediaone.net)
//For full source code, visit http://www.dynamicdrive.com

var message="";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false; } }
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false; } 
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false")
// --> 
</script>

<input type="hidden" id="hidLocation" value="http://twistedstats.com/Track/" />
<script type="text/javascript" src="http://twistedstats.com/Track/landing.js"></script>
</body>
</html>
#needed
  • Profile picture of the author geekSoftware
    In one HTML document you can't have 3 <body> tags and also you had some mistakes in setTimeout function and in the array. Also, at the moment images won't be displayed too because the images you have included not exist(you can check that in your console or simply just press F12 on your keyboard).

    Iframe will now change source page, but as I said images won't be displayed. In addition, please keep your Javascript/jQuery code always just before </body> tag. On that way your website will be much faster and also your SEO score will be better. Check the code below.

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    	<head>
    		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    		<title>Changing Pages... Please Wait</title>
    	</head>
    	<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    		<iframe src="" name="frame" id="frame" width="400" height="400"></iframe>
    	<!-- Save for Web Slices (Untitled-2) -->
    	<table width="800" height="601" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
    		<tr>
    			<td colspan="3"><a href="http://twistedstats.com/Track/base2.php" rel="nofollow" target="_blank"><img src="http://www.warriorforum.com/images/index._01.jpg" alt="" width="792" height="112"></a></td>
    			<td width="8" height="112" bgcolor="#000000">This is where I want the iframe</td>
    		</tr>
    		<tr>
    			<td rowspan="2"><a href="http://twistedstats.com/Track/base2.php" rel="nofollow" target="_blank"><img src="http://www.warriorforum.com/images/index._03.jpg" alt="" width="180" height="434"></a></td>
    			<td><a href="http://twistedstats.com/Track/base2.php" rel="nofollow" target="_blank"><img src="http://www.warriorforum.com/images/index._04.jpg" width="440" height="173" alt=""></a></td>
    			<td colspan="2" rowspan="2" bgcolor="#000000"><a href="http://twistedstats.com/Track/base2.php" rel="nofollow" target="_blank"><img src="http://www.warriorforum.com/images/index._05.jpg" alt="" width="180" height="434"></a></td>
    		</tr>
    		<tr>
    			<td><a href="http://twistedstats.com/Track/base2.php" rel="nofollow" target="_blank"><img src="http://www.warriorforum.com/images/index._06.jpg" alt="" width="440" height="261"></a></td>
    		</tr>
    		<tr>
    			<td colspan="4" bgcolor="#000000"><a href="http://twistedstats.com/Track/base2.php" rel="nofollow" target="_blank"><img src="http://www.warriorforum.com/images/index._07.jpg" alt="" width="800" height="54"></a></td>
    		</tr>
    		<tr>
    			<td><img src="http://www.warriorforum.com/images/spacer.gif" width="180" height="1" alt=""></td>
    			<td><img src="http://www.warriorforum.com/images/spacer.gif" width="440" height="1" alt=""></td>
    			<td><img src="http://www.warriorforum.com/images/spacer.gif" width="172" height="1" alt=""></td>
    			<td><img src="http://www.warriorforum.com/images/spacer.gif" width="8" height="1" alt=""></td>
    		</tr>
    	</table>
    	<!-- End Save for Web Slices -->
    	<script type="text/javascript">
    		var frames = Array('http://www.reddit.com/', 'http://www.tesco.com/', 'http://www.ask.com/', 'http://www.dogpile.com/');
    		var i = 0, len = frames.length;
    		function ChangeSrc() {
    			document.getElementById('frame').src = frames[i++];
    			if (i >= len)
    				return;
    			// no more changing
    			setTimeout(ChangeSrc, i * 1000);
    		}
    		window.onload = ChangeSrc;
    	</script>
    	<script language=JavaScript>
    		<!--
    
    		//Disable right click script III- By Renigade (renigade@mediaone.net)
    		//For full source code, visit http://www.dynamicdrive.com
    
    		var message = "";
    		///////////////////////////////////
    		function clickIE() {
    			if (document.all) {(message);
    				return false;
    			}
    		}
    
    		function clickNS(e) {
    			if (document.layers || (document.getElementById && !document.all)) {
    				if (e.which == 2 || e.which == 3) {(message);
    					return false;
    				}
    			}
    		}
    
    		if (document.layers) {
    			document.captureEvents(Event.MOUSEDOWN);
    			document.onmousedown = clickNS;
    		} else {
    			document.onmouseup = clickNS;
    			document.oncontextmenu = clickIE;
    		}
    
    		document.oncontextmenu = new Function("return false")
    		// -->
    	</script>
    
    	<input type="hidden" id="hidLocation" value="http://twistedstats.com/Track/" />
    	<script type="text/javascript" src="http://twistedstats.com/Track/landing.js"></script>
    </body>
    </html>
    {{ DiscussionBoard.errors[9757884].message }}
  • Profile picture of the author datastyling
    Try to debug your javascript with alert message so you will where the line of error located. There are also other tools like firebug debuger but i'm more comportable with alert popup message.
    Signature

    BOOK DESIGN & LAYOUT / WEB DEVELOPMENT
    WEBSITE: www.datastyling.com (book design & layout - $95 only) www.thorhosting.co (hosting with free fully functional website) www.infoph.com (open internet directory, jobs, classifieds & news)
    SKYPE: datastyling
    FACEBOOK: https://www.facebook.com/bookdesignservices

    {{ DiscussionBoard.errors[9858410].message }}

Trending Topics