Sign in to follow this  
Peter

Iframe + Auto scroll down after loaded

Recommended Posts

I wonder if this is possible, but I want an Iframe automatically scroll down after it is loaded, no refresh needed

<div align="center">History</div>

<div align="center">

<iframe src="http://www.axieblast.com/shout/history.php" width="96%" height="50" scrolling="auto"></iframe></div>


This is my current code, and I dont know what to do to make it autojatically scroll down

Need it ASAP thanks

Share this post


Link to post
Share on other sites

Replace the current history.php body tag with this:

<body onload="pageScroll()">



And put this javascript in the head tag:

<!-- function pageScroll() { window.scrollBy(0,50); scrolldelay = setTimeout('pageScroll()',200); //Increase this # to slow down, decrease to speed up scrolling } //--> </script>

<script type="text/javascript">








Share this post


Link to post
Share on other sites

OK, just gonna put that in, been busy messing around the forum's template haha

No it doesnt work, It is a php file so there are no body and head, however I found </body> though

Share this post


Link to post
Share on other sites

Wow theres no way for me to write the script! I didnt even learn php, all I know is <echo "blah blah blah blah">, and I am not even sure if that was in the right format. All I can do is use dreamweaver LOL...

but look at the history.php www.axieblast.com/blah/history.php, it doesnt look like it has some overall_header or somethin like a phpbb...

Share this post


Link to post
Share on other sites

look at the top of the page you're trying to insert the script in (history.php)-make sure you're viewing it with cpanel's file editor or similar, not just loading the page and hitting view source (which won't show the underlying php code). There will probably be one or more commands that look like

include (somepage.php);


Then look at the code for each of the "somepage.php" files; one of them should include the <head> and <body>
Or you could post the source code for somepage.php and I'll see if I can find the file you need to edit.

Edited by elyk

Share this post


Link to post
Share on other sites
OK, just gonna put that in, been busy messing around the forum's template haha

No it doesnt work, It is a php file so there are no body and head, however I found </body> though



Just add this on top of your script:

 


<html><head>

<script type="text/javascript">

<!--

function pageScroll() {


window.scrollBy(0,50);

scrolldelay = setTimeout('pageScroll()',200); //Increase this # to slow down, decrease to speed up scrolling


}

//-->

</script>

</head>

<body onload="pageScroll()">

</html>

<?php


and then go on with your PHP part. It works fine for me. Hope it does the same for you too

Share this post


Link to post
Share on other sites

Hi,

I've found a "creative" solution to this IFRAME auto-scroll issue...

Solution? Create a container-DIV, set a fixed height on it (For ex: style="height: 1000px"), then use an auto-scroll

script to scroll down the page.

Now...

For the IFRAME: set it up as you wish (with attributes, styling, etc.), but create a fixed height (For ex:

style="height: 1000px"), preferably the same as the DIV. The DIV should surround (be the container of) the IFRAME

itself.

Now, the DIV and the IFRAME will be of the same height, and the scrolling script will give the APPEARANCE that the

IFRAME itself is scolling down, while it's actually the containing DIV (page) that does it.

I hope this helps!

- Christian Aglen


Example script:
-------------------------------------
<script language=JavaScript>

function ScrollDown() {
window.scrollBy(0,10);
scrolldelay = setTimeout('pageScroll()',100);
}

window.onload=ScrollDown;

</script>

<div style="height: 1000px;">

<iframe src="http://www.urlgoeshere.com" frameborder="0" scrolling="no" marginwidth="0" marginheight="0" width="100%"

height="1000px" style="padding: 0; margin: 0; border: 0;"></iframe>

</div>
-------------------------------------

Share this post


Link to post
Share on other sites

;) not-too-bad solution! many thanks

[Mod edit (Zarel): You appear to have had some sort of hidden link here. I've removed it. Please note that spamming is against the rules.]

Edited by Zarel

Share this post


Link to post
Share on other sites

Hope this code is helpful for you..

<script language=JavaScript1.2>

//change 1 to another integer to alter the scroll speed. Greater is faster

var speed=1

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

function initialize(){

startit()

}

function scrollwindow(){

if (document.all &&

!document.getElementById)

temp=document.body.scrollTop

else

temp=window.pageYOffset

if (alt==0)

alt=2

else

alt=1

if (alt==0)

curpos1=temp

else

curpos2=temp

if (curpos1!=curpos2){

if (document.all)

currentpos=document.body.scrollTop+speed

else

currentpos=window.pageYOffset+speed

window.scroll(0,currentpos)

}

else{

currentpos=0

window.scroll(0,currentpos)

}

}

function startit(){

setInterval("scrollwindow()",400)

}

window.onload=initialize

</SCRIPT>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this