Hello:
I am working with Javascript and IFrames.
I have a single web page with a single IFrame. There are several links that can be clicked to display content within the IFrame.
What I would like to do is that if a user clicks a link it will display the IFrame content. If the user clicks the same link again and the IFrame is already displayed, it will hide the frame. However, if the user clicks a different link the content will change and the frame will remain being displayed.
I have already completed this task, however, I had to change some code in order for the browsers 'back' button to function properly.
Here is the code:
function Hide(frameid) {
var frm = document.getElementById(fr
ameid);
var url = frm.src;
if(frm.style.display=='non
e') {
frm.style.display='block';
frm.contentWindow.location
.replace('
testpage1.
html');
} else {
if(ulr=='testpage1.html') {
frm.style.display='none';
} else {
frm.style.display='block';
frm.contentWindow.location
.replace('
testpage1.
html');
}
}
etc...
}
The problem is that i have to use:
" fmr.contentWindow.location
.replace('
testpage1.
html'); "
instead of just
" frm.src = 'testpage1.html';
The reason being is that I want the browsers 'back' button to not navigate the pages within the IFrame.
If I try to evaluate frm.src after using the replace feature it will return null. For some reason I am unable to evaluate the frames src at all after using the replace feature. This being so it is preventing me from knowing what content is being displayed.
Any suggestions would be appreciated.
Thanks
Start Free Trial