PDA

View Full Version : Iframe SSI script II - bounces to bottom of page



aya_13
06-20-2008, 02:41 AM
1) Iframe SSI script II

2) http://www.dynamicdrive.com/dynamicindex17/iframessi2.htm

3) If you go to this website i am making, you can see the issue. i have searched the forums here but was unable to find a fix. if someone can point me to the correct thread or help with a fix, that would be great thank you...

http://www.visitpromcountry.com/search.htm
Don't enter any data, just hit search

When the results come back, you can see the IFrame script nicely resizes the page. Scoll down to the entry:
At Ripplebrook by the Prom
And hit the 'click for more details' option

Here is the problem
The script resizes the page nicely again, but leaves you sitting at the bottom of the page and site users need to scroll up to get to the top of the listing. i want them once they click the 'click for more details' option - to end up at the top of the new file, not the bottom. can some one please help me?

thank you...
:)

Nile
06-20-2008, 02:46 AM
In features.php change <body> to this:


<body onLoad="scrollTo(0,0)">

That should bring you to the top of the page on anything.

aya_13
06-20-2008, 03:06 AM
Hi Nile,

thank you for helping me. i have dowloaded the file and added in the code as you suggested, but it is still doing the same thing? do you have any other ideas about why it might be doing it?

thanks heaps,
aya

:)

Nile
06-20-2008, 03:10 AM
Oops, sorry. That was my fault. Put it back(although it doesn't hurt at all), you can either put it back to <body> or just leave it. I see that you also have scrollTo on the search.htm, but it's in wrong. Make your <body> section this:


<BODY onLoad="scrollTo(0,0);MM_preloadImages('images/icon1a.gif','images/icon2a.gif','images/icon3a.gif','images/icon4a.gif','images/icon5a.gif','images/icon6a.gif','images/icon7a.gif','images/icon8a.gif','images/accomword1a.gif','images/accomword2a.gif','images/accomword3a.gif')">

You had two different onLoads.

aya_13
06-20-2008, 03:23 AM
Hi Nile!

thanks...

I have removed it from features.php - and left it in on search.htm with the code you suggested.

but the problem is still there when you click on the 'At Ripplebrook by the Prom' from the search results...

if you have anything else i could try, that would be great thanks!
aya

:)

Nile
06-20-2008, 03:31 AM
Ahh, thats me being an idiot again! The page isn't reloading when you click on something in an iframe... Hmm, lemme think about this. Maybe ddadmin can swoop in and save me... :) lol

aya_13
06-20-2008, 03:40 AM
thanks heaps!

really appreciate it hey

:)

Nile
06-20-2008, 03:41 AM
Yeah, I'll still be thinking, but I was just so dumb, I should've thought. Sorry for my idioticle self, lol. :-/

aya_13
06-20-2008, 03:54 AM
hey no worries!

it is so cool you replied to me straight away like that. i am really stuck and it is the first time i have logged in here for assistance, and it is great that you guys help out like this anyway!

have been battling this silly thing for a while! and am not a great coder, as you can now probably tell!!!
i do more design side of things, but because this is my project i am stuck with the problem!

if you can think of anything else, or if anyone else can assist, i am just so grateful for that!

thanks,
aya
:)

Nile
06-20-2008, 01:16 PM
Ok, change this:


<BODY onLoad="scrollTo(0,0);MM_preloadImages('images/icon1a.gif','images/icon2a.gif','images/icon3a.gif','images/icon4a.gif','images/icon5a.gif','images/icon6a.gif','images/icon7a.gif','images/icon8a.gif','images/accomword1a.gif','images/accomword2a.gif','images/accomword3a.gif')">

To this:


<BODY onLoad="makeScroll('MAIN');MM_preloadImages('images/icon1a.gif','images/icon2a.gif','images/icon3a.gif','images/icon4a.gif','images/icon5a.gif','images/icon6a.gif','images/icon7a.gif','images/icon8a.gif','images/accomword1a.gif','images/accomword2a.gif','images/accomword3a.gif')">

Then, in your javascript, add this:


function makeScroll(idFra){
if(document.getElementById(idFra).src != "databases/searchoursite.htm"){
scrollTo(0,0);
}
setTimeout("makeScroll('"+idFra+"')",1000);
}

I hope that works. ;)

aya_13
06-21-2008, 11:53 AM
hey Nile!
thanks!

something has definitely worked!
When I placed the Javascript in the header of search.htm - it didn't work - but when I changed it to:

>>>


function makeScroll(idFra){
if(document.getElementById(idFra).src != "databases/features.php"){
scrollTo(0,0);
}
setTimeout("makeScroll('"+idFra+"')",1000);
}


>>>

i.e. changed it to features.php
it certainly did something!
Now it bounces to the top all the time - and that is great! but, it wont stay at the place on your page where you are once you start viewing and scrolling the page, it is always trying to bounce to the top now, even as you scroll intentionally!

if you could suggest something additional to prevent this - it would be perfect!

thanks heaps,

aya

:)

aya_13
06-21-2008, 12:21 PM
hi Nile!

i think i have fixed it!!!
well, actually you have fixed it!!!
:)

i played around with the timeout - and set to 10000 instead of 1000 - am going to have a good play around with it on some browsers - and will let you know how i go!

thanks so much - your a star!
aya
:)

aya_13
06-21-2008, 12:32 PM
hi Nile,

i have worked out the timeout scroll (i think!) - and each time i add a 0 it delays the time it will take to jump to the top of the page. that is cool. i have got it sitting at the right time now, so it works great.

the only issue is, it keeps doing it. so after the same time period, it bounces to the top again. is there a way to set the code so it only jumps to the top of the page once each time you load the page? and not every x seconds?

thanks heaps!

aya
:)

Nile
06-22-2008, 02:23 AM
Try this:


function makeScroll(idFra){
if(document.getElementById(idFra).src == "databases/features.php"){
scrollTo(0,0);
}
setTimeout("makeScroll('"+idFra+"')",1000);
}

Making the timeout longer won't do, it will just simply jump to the top later then 1 second.
And only if that doesn't work try this(try the other one first):


function makeScroll(idFra){
var ur13l = document.url;
var po13s=findIt.indexOf('?title');
if(document.getElementById(idFra).src == ur13l.replace(ur13l.substr(po13s),"")){
scrollTo(0,0);
}
setTimeout("makeScroll('"+idFra+"')",1000);
}

aya_13
06-22-2008, 07:52 AM
Hi Nile!

thanks - and i have tried both - the first here (which still bounces all the time):
http://www.visitpromcountry.com.au/search.htm

and the second here (does not bounce at all):
http://www.visitpromcountry.com.au/search1.htm

if you have any other ideas to try, that would be heaps great thanks!

:)
aya

Nile
06-22-2008, 11:50 AM
Lol, oops. Make it this:


function makeScroll(idFra){
var ur13l = document.url;
var po13s=ur13l.indexOf('?title');
if(document.getElementById(idFra).src == ur13l.replace(ur13l.substr(po13s),"")){
scrollTo(0,0);
}
setTimeout("makeScroll('"+idFra+"')",1000);
}
I was using an invalid variable. :)

aya_13
06-23-2008, 03:13 AM
Hi Nile!

thanks for not giving up on me!

I added the new code to:
http://www.visitpromcountry.com.au/search.htm

but now it does not bounce to the top at all again!

any other ideas greatly appreciated!
:)

thanks,
aya

Nile
06-23-2008, 03:22 AM
God... DDADMIN!! JOHN!!! HELP ME!!
This is impossible.
I've got one question.
Why do you have to use frames?

aya_13
06-23-2008, 03:37 AM
Hi Nile,

i know - it is unfortunate, the site is cobbled together to integrate a few different applications, and it is the only way i could put it together with all these different apps seamlessly for the site users - so i had to go iframes.

and all worked perfectly except for this scrolling!!!

thanks so much for your assistance, and if anyone can help me fix this i am so thankful

aya
:)

Nile
06-23-2008, 03:50 AM
There's one more thing that you can try. Just wait one second.

Nile
06-23-2008, 03:52 AM
Remove all the changes I made, and change:


function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}

To:


function loadintoIframe(iframeid, url){
scrollTo(0,0);
if (document.getElementById)
document.getElementById(iframeid).src=url
}

aya_13
06-23-2008, 04:36 AM
hi Nile!

tried the new code, but still no luck:
http://www.visitpromcountry.com.au/search.htm

feel like i am wearing you out!
sorry... but immense thanks hey...

aya
:)

Nile
06-23-2008, 01:44 PM
Replace(undo me changes first):


/***********************************************
* IFrame SSI script II- Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["myframe"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeIframe(iframeids[i])
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}

function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe)
}
}
}

function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}

if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)
else
window.onload=resizeCaller

With:


/***********************************************
* IFrame SSI script II- Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["myframe"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {
scrollTo(0,0);
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeIframe(iframeids[i])
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}

function resizeIframe(frameid){
scrollTo(0,0);
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe)
}
}
}

function readjustIframe(loadevt) {
scrollTo(0,0);
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
scrollTo(0,0);

if (document.getElementById)
document.getElementById(iframeid).src=url
}

if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)
else
window.onload=resizeCaller

aya_13
06-23-2008, 02:55 PM
hi Nile!

still no joy, but thanks again for your support:
http://www.visitpromcountry.com.au/search_test.htm

that iframe script is to measure the hight of the iframe content, and adjust the page header and footer to fit (if that helps you at all)...

thank you,
aya
:)

Nile
06-23-2008, 09:53 PM
Sorry, now I defendantly got nothing.

aya_13
06-27-2008, 03:02 AM
Hi Nile,

first i wanted to say thank you very much for assisting me with your help, i really appreciated it. i run things here by myself and i struggle, with $ and capabilities, trying to run my own little show so i don't have to get hassled working for a big corp. so thank you!

i also wanted to let you know how i resolved it, as i am new here and not familiar with how to do this - but i wanted to give the code in case it helps someone else in the same predicament. should i start a new thread with my original problem and the code that fixed the scroll issue? or should i just leave it here?


i found a javascript geek and he gave me this to add which worked:

to fix I added:

// scroll to the top to make it look like we've loaded a new page
scrollTo(0,0);
... to the resizeIframe function.


thank you so much again Nile!

aya
:)