woodstock
12-20-2006, 11:28 PM
1) Script Title: iframe SSI 2
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/iframessi2.htm
3) Describe problem: There's no problem with this script. I have implemented it on a page to load content into the iframe. Next to the iframe is a set of links. In the mark-up I have inserted onclick events which work fine, but now I want to refine it and remove the javascript from the mark-up altogether. I've tried using the bit of script included below, and messed around with it a lot but can't get it to work.
function prepareLinks() {
alert("loaded")
if (!document.getElementsByTagName) return false;
if (!document.getElementById("no videolist"))
alert("no videolist");
if (!document.getElementById("no stobbit"))
alert("no stobbit");
if (!document.getElementById("placeholder"))
alert("no placeholder");
//these are just tests to see where the problem lies
//this is the functional bit:
var list = document.getElementById("videolist"); //a div tag containing the links
var links = list.getElementsByTagName("a");
var placeholder = document.getElementById("placeholder"); //the id of the iframe
for ( var i=0; i < links.length; i++) {
links[i].onClick = function() {
return loadintoIframe("placeholder",this);
}
}
}
window.onload = prepareLinks()
The bit of script that actually loads the content into the iframe is as follows:
function loadintoIframe(iframeid, url) {
if (!document.getElementById) return;
document.getElementById(iframeid).src=url
}
As mentioned this is working with the inline event handlers, as you can see by visiting the page in question following this link:
http://www.tonycaunce.pwp.blueyonder.co.uk/videomenu.html
The script in question is myiframe.js, which contains the three lines quoted above, plus the prepareLinks function and window.onload event. I've tried to place the link to the script at various places in the body of the page to test whether the document object has completely loaded before the script runs, that's what the tests at the beginning were for.
Anyway, I can't figure this out myself. I need help, if anyone can give me some pointers,
thanks
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/iframessi2.htm
3) Describe problem: There's no problem with this script. I have implemented it on a page to load content into the iframe. Next to the iframe is a set of links. In the mark-up I have inserted onclick events which work fine, but now I want to refine it and remove the javascript from the mark-up altogether. I've tried using the bit of script included below, and messed around with it a lot but can't get it to work.
function prepareLinks() {
alert("loaded")
if (!document.getElementsByTagName) return false;
if (!document.getElementById("no videolist"))
alert("no videolist");
if (!document.getElementById("no stobbit"))
alert("no stobbit");
if (!document.getElementById("placeholder"))
alert("no placeholder");
//these are just tests to see where the problem lies
//this is the functional bit:
var list = document.getElementById("videolist"); //a div tag containing the links
var links = list.getElementsByTagName("a");
var placeholder = document.getElementById("placeholder"); //the id of the iframe
for ( var i=0; i < links.length; i++) {
links[i].onClick = function() {
return loadintoIframe("placeholder",this);
}
}
}
window.onload = prepareLinks()
The bit of script that actually loads the content into the iframe is as follows:
function loadintoIframe(iframeid, url) {
if (!document.getElementById) return;
document.getElementById(iframeid).src=url
}
As mentioned this is working with the inline event handlers, as you can see by visiting the page in question following this link:
http://www.tonycaunce.pwp.blueyonder.co.uk/videomenu.html
The script in question is myiframe.js, which contains the three lines quoted above, plus the prepareLinks function and window.onload event. I've tried to place the link to the script at various places in the body of the page to test whether the document object has completely loaded before the script runs, that's what the tests at the beginning were for.
Anyway, I can't figure this out myself. I need help, if anyone can give me some pointers,
thanks