chesterthebear
Programmer
I have a problem so weird I'm not sure I know where to turn.
I have a page with an iframe. Click on a menu item on that page and the item opens in that iframe.
Each page assigns a unique name/id to the iframe, so that multiple instances of the page may exist in the browser.
However, when I execute javascript in the target script in the iframe, and then click on another menu item in the top page, the target script opens in a new window or tab instead of in the targeted iframe. After hours of experimentation, it appears that the page works as intended until a javascript function is called within the iframe.
I don't even need to submit the form for things to go wrong. All I need to do is call the javascript function.
Here's an extract...
On the top page....
HTML Code:
And in edition.php...
It's not just this specific function either. There are other scripts with different functions, all causing the same result, that is, that the top page iframe appears to lose its identity when the function in the target iframe is called.
Finally, and this is perhaps the weirdest part of all, the problem happens in IE, Chrome, Iron, Safari and Opera, but not in Firefox.
I've just about exhausted ideas on this, and I hope the gurus here can point me in the right direction.
Any thoughts?
CTB
I have a page with an iframe. Click on a menu item on that page and the item opens in that iframe.
Each page assigns a unique name/id to the iframe, so that multiple instances of the page may exist in the browser.
However, when I execute javascript in the target script in the iframe, and then click on another menu item in the top page, the target script opens in a new window or tab instead of in the targeted iframe. After hours of experimentation, it appears that the page works as intended until a javascript function is called within the iframe.
I don't even need to submit the form for things to go wrong. All I need to do is call the javascript function.
Here's an extract...
On the top page....
HTML Code:
Code:
<div name='menu'>
<p><a href='/edition.php' target='content123456'>Edit Editions</a></p>
</div>
<div>
<iframe name="content123456" id="content123456" frameborder="0" scrolling="auto" width="810" height="1000"></div>
And in edition.php...
Code:
<head>
<script language='javascript'>
function setmonth()
{
var d = document.getElementById('date').value; //expects the format yyyy-mm-dd
var dx = d.split("-");
switch(dx[1])
{
case "01": m = "January"; break;
case "02": m = "February"; break;
case "03": m = "March"; break;
case "04": m = "April"; break;
case "05": m = "May"; break;
case "06": m = "June"; break;
case "07": m = "July"; break;
case "08": m = "August"; break;
case "09": m = "September"; break;
case "10": m = "October"; break;
case "11": m = "November"; break;
case "12": m = "December"; break;
}
document.getElementById('month').value = m;
var mx = dx[1] - 1;
var edate = new Date(dx[0], mx, dx[2]);
var days = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]
var day = days[edate.getDay()]
var dn = dx[2];
var n = dn.substring(0,1);
if(n=="0")
{
dn = "x" + dn;
dn = dn.replace("x0","");
}
var title = day+" "+m+" "+dn;
neame = document.getElementById('name').value;
if(ename=="")
{
document.getElementById('name').value = title;
}
}
</script>
</head>
<body>
<h1>Edition Management</h1>
<form name='ed' id='ed' method='POST' action='/edition.php' target='_self'>
<table>
<tr>
<td align='right'>Edition Name</td>
<td><input style='font-size:8pt; width: 200px' type='text' name='name' id='name' size='20' ></td>
</tr>
<tr>
<td align='right'>Date</td>
<td>
<input type='text' style='font-size:8pt; width: 200px' name='date' id='date' size='20' onchange="setmonth()">
</td>
</tr>
</table>
</form>
It's not just this specific function either. There are other scripts with different functions, all causing the same result, that is, that the top page iframe appears to lose its identity when the function in the target iframe is called.
Finally, and this is perhaps the weirdest part of all, the problem happens in IE, Chrome, Iron, Safari and Opera, but not in Firefox.
I've just about exhausted ideas on this, and I hope the gurus here can point me in the right direction.
Any thoughts?
CTB