473,394 Members | 1,108 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

[Netscape] href in iframe hangs when calling function in parent window

Hi,

the following code has the mentioned behaviour:

<html>
<head>
<script type="text/javascript">
function newA() {
for (i=0;i<3;i++) {
var a = window.frames[0].document.createElement("a");
a.innerHTML = "anchor "+i;
a.setAttribute("innerHTML", "anchor "+i);
a.setAttribute("href", "javascript:parent.h_click()");
window.frames[0].document.body.appendChild(a);
}
}
function h_click() {
alert('ciao!');
}
</script>
</head>
<body>
<input type="button"
onclick="document.body.appendChild(document.create Element('iframe'))"
value="new iFrame">
<input type="button" onclick="newA()" value="new anchor">
</body>
</html>
The same stuff adapted to IE6 works.

Suggestions?

Thnx,

Christian

Jul 20 '05 #1
1 4298
Christian Radermacher wrote:
Hi,

the following code has the mentioned behaviour:

<html>
<head>
<script type="text/javascript">
function newA() {
for (i=0;i<3;i++) {
var a = window.frames[0].document.createElement("a");
a.innerHTML = "anchor "+i;
a.setAttribute("innerHTML", "anchor "+i);
a.setAttribute("href", "javascript:parent.h_click()");
window.frames[0].document.body.appendChild(a);
}
}
function h_click() {
alert('ciao!');
}
</script>
</head>
<body>
<input type="button"
onclick="document.body.appendChild(document.create Element('iframe'))"
value="new iFrame">
<input type="button" onclick="newA()" value="new anchor">
</body>
</html>

The same stuff adapted to IE6 works.

Suggestions?

Thnx,

Christian


<script type="text/javascript">
function newA() {
for (i=0;i<3;i++) {
var a = window.frames[0].document.createElement("a");
var t = window.frames[0].document.createTextNode("anchor" + i);
a.setAttribute("href", "#");
a.onclick = parent.h_click;
a.appendChild(t);
window.frames[0].document.body.appendChild(a);
}
}
function h_click() {
alert('ciao!');
return false;
}
</script>

Works in Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5b)
Gecko/20030904

Note that you shouldn't be setting HREF to "javascript:..." <url:
http://jibbering.com/faq/#FAQ4_24 /> and you should be returning false
from the onclick event.

Oddly enough, the links don't appear with the correct text decoration in
the version of Mozilla I tested it in. Nor does the mouse cursor change
when I roll over them. However, when clicked, they do alert "ciao!".

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: deko | last post by:
I'd like to use a bit of code in the OnOpen event of a report: =rptOpen(Me.ReportName), (Me.Tag) --this doesn't work This does work: Private Sub Report_Open(Cancel As Integer)...
1
by: Gregory Hassett | last post by:
Hi, I have a web service called GetComputerNameAndDescription which I can call from the main thread of my app. If I call it from a separate thread, however, it hangs on the call to Invoke() -- but...
0
by: Materialised | last post by:
Hi All, My program is hanging when I call a function for convert a image file to base64. I am wondering if I handled the call to this function within a different thread if it would make any...
4
by: Peter Afonin | last post by:
Hello, I have a weirdest issue I've ever had. I have a function that enters some data into the Oracle table and returns the sequential row number for the new record (autonumber): Private...
1
by: kambakht | last post by:
I am using an iframe in my index.aspx thus all the webforms in application navigate in this iframe. While main appication links are present on the top of page above iframe, in main window. These...
2
by: VBLearner | last post by:
How to close the parent and all child forms together at once when click on parent window's close button X?
4
by: astri | last post by:
#include "Unit1.h" #include "math.h" #include "fixed_math.hpp" #include "algorithm.h" #define MBIT 0x4000 #define CBIT 16 long constbl; void __fastcall TForm1::Button1Click(TObject...
0
by: ngrTerry | last post by:
When I change from the code view to the design view of a form in Visual Studio 2005 (VB.NET) The design environment hangs for up to five minutes with a blank screen where the form should be. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.