PDA

View Full Version : Scrollable Iframe JavaScript problem



Hepple
01-30-2007, 01:11 AM
1) Script Title: Scrollable IFRAME

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/iframescroll.htm

3) Website with problem: http://www.callus.cc/v2

3) Describe problem: My problem is that the following JavaScript ...


<script language="JavaScript1.2">

//Scrollable content III- By http://www.dynamicdrive.com

var speed, currentpos=curpos1=0,alt=1,curpos2=-1

function initialize(){
if (window.parent.scrollspeed!=0){
speed=window.parent.scrollspeed
scrollwindow()
}
}

function scrollwindow(){
temp=(document.all)? document.body.scrollTop : window.pageYOffset
alt=(alt==0)? 1 : 0
if (alt==0)
curpos1=temp
else
curpos2=temp

window.scrollBy(0,speed)
}

setInterval("initialize()",10)

</script>

... does't like to be on the same page as my PHP script. In the installation instructions it says "Insert the below script in the page being loaded in the iframe, at the very end of the document source", which for me happens to be dynamic PHP.

It works perfectly in Firefox but I get an error in IE saying "Error: Object required.". Sometimes it does actually work in IE, it kinda chooses to work when it wants to.

Maybe someone could update the JavaScript for me? Thanks!

jscheuer1
01-30-2007, 06:29 AM
Your page has no body and you've not inserted the script at the end as instructed. You might be able to get away with changing:


setInterval("initialize()",10)

to:


onload=function(){setInterval("initialize()",10)}

But, you may need to have a body tag (and maybe even html and head tags as well, body tag only shown below):


<body>
<table width="100&#37;" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="5" colspan="2"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td width="816" valign="bottom"><span class="style2"><strong>Whooooooooow!</strong></span></td>
</tr>
<tr>
<td>&nbsp;</td>
<td class="style3">Mother****ing testing baby, I am your father you sausage jocky!</td>
</tr>
<tr>
<td>&nbsp;</td>
<td></td>
</tr>
</table>
</body>

And place all of your content in it, keep style in the head.

Hepple
01-30-2007, 10:43 AM
Thanks for your help. But the problem was because the external page was an index.php with only this code ...


<?
include_once("gigs.php");
gigs();
?>

... I was putting the JavaScript in the gigs.php file instead of the index.php. Everthing seems to be fine and dandy now.