473,498 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[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 4304
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
11022
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
3589
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
890
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
1366
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
8072
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
1622
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
10624
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
820
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
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7002
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
7165
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
7205
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...
1
6887
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5462
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4910
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
291
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.