Click to See Complete Forum and Search --> : On event handler causing script to fail


ragawu
10-14-2003, 06:12 PM
Hi there,
I'm having problems with the following script, I'm trying to load external html files into a layer using a dropdown menu.

here are the javascript functions:


ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false

function loadSource(id,nestref,url) {
if (ns4) {
var lyr = (nestref)? eval('document.'+nestref+'.document.'+id) : document.layers[id]
lyr.load(url,lyr.clip.width)
}
else if (ie4) {
parent.bufferFrame.document.location = url
}
}
function loadSourceFinish(id) {
if (ie4) document.all[id].innerHTML = parent.bufferFrame.document.body.innerHTML
}

and here is the html that calls the functions:


<form
<select name="select" onchange="loadSource('contentLayer',Layer51, 'diaries/eighties.htm')">
<option selected>Choose from the following...</option>
<option value="http://www.lapsuslinguae.co.uk/diaries/jan02.htm">January 2002 Tour</option>
<option value="http://www.lapsuslinguae.co.uk/diaries/eighties.htm">Eighties Matchbox Tour</option>
<option value="http://www.lapsuslinguae.co.uk/diaries/april03.htm">April 2003 Tour</option>
<option value="http://www.lapsuslinguae.co.uk/diaries/catpart1.htm">The Cathouse Incident - Part 1 of 3</option>
<option value="http://www.lapsuslinguae.co.uk/diaries/catpart2.htm">The Cathouse Incident - Part 2 of 3</option>
</select>
</form>


and finally, this is what an excerpt of the code that is contained in the external html files: (this is used to transfer the data from an iframe buffer to the layer in IE)

<BODY onLoad="parent.loadSourceFinish('contentLayer')">


If anyone can tell me why this does not work, please respond. I know that the functions work correctly if I call them using a normal link, so it must be the implmentation of the drop down menu that is at fault. However, I will only be calling this function using a drop down menu, so altering the functions is fine.


Thanks!
Alasdair

gil davis
10-14-2003, 09:26 PM
Try this:
<select name="select" onchange="loadSource('contentLayer', Layer51, this.options[this.selectedIndex].value)">
At least you'll get the desired URL to the function.

ragawu
10-14-2003, 09:35 PM
Hi thanks, I actually found out the problem was from me sending full urls rather than relative ones.

Now the problem is that when I lopad html into the DHTML layer, rather than stay within the constraints of the layer, the text spills out and carrys on down the page.

Any understanding why?