473,386 Members | 1,775 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,386 software developers and data experts.

Rewriting itself

The function below (as fc.js) works with IE6.0, NS4.2 NS7.1. It
rewrites itself increasing the number.

However if I comment out the othervise unnecessary window.alert, it
still works with NS but falls into and endless loop in IE. The alert
helps only after the scr=fc.js line, otherwise the first recursion
causes the endless loop in IE

Any cue for the reason or more preferably workaround is appreciated. I
include the text for fc.js and the calling test.html

laszlo

***** fc.js *****

function testrut(cnt) {
var teststr = "Hello";
var nwf = window.open("", "testecske", "width=200,height=200");

cnt++;

nwf.document.writeln("<HTML><HEAD>");
nwf.document.writeln("<TITLE>recursive javascript</TITLE></HEAD>");

nwf.document.writeln("<BODY BGCOLOR=silver ><FORM><CENTER>");
nwf.document.writeln(teststr + cnt + "<BR><BR>");
nwf.document.writeln("<INPUT TYPE=BUTTON VALUE=repeat
onclick='testrut(" + cnt + ");'><BR><BR>");
nwf.document.writeln("<INPUT TYPE=BUTTON VALUE=close
onclick='window.close();'><BR><BR>");
nwf.document.writeln("</CENTER></FORM>");
nwf.document.writeln("<SCRIPT LANGUAGE='JavaScript1.2'
SRC='fc.js'></SCRIPT>");
nwf.document.writeln("</BODY></HTML>");
window.alert('hohoho');
nwf.document.close();
}

***** test.html *****
<HTML><HEAD>
<SCRIPT LANGUAGE='JavaScript1.2' SRC='fc.js'></SCRIPT>
<TITLE>Test</TITLE></HEAD>
<BODY><FORM><CENTER>
<INPUT TYPE=BUTTON VALUE=start onclick=testrut(0);>
</CENTER></BODY></HTML>
Jul 23 '05 #1
1 1539
I've get no answer, but fortunatelly found the resolution. The trick
is to put a hidden button into the calling html, set the id as
parameter, and for rewriting click this button from javascript. This
seems to be w/o hazard.

http://www.lzkiss.netfirms.com/test/recurse.html

*** fc.js ****
function testrut(name1, name2) {
var widget = document.getElementById(name1);
var cnt = widget.value;
cnt = cnt.replace(/rrr/i, '');
var teststr = "Hello=" + cnt;
cnt = parseInt(cnt) +1;
var nwf = window.open("", "testecske", "width=200,height=200");
nwf.document.writeln("<HTML><HEAD>");
nwf.document.writeln("<SCRIPT TYPE='text/JavaScript'
LANGUAGE=JavaScript1.2>");
nwf.document.writeln("var id1='" + name1 + "'");
nwf.document.writeln("var id2='" + name2 + "'");
nwf.document.writeln("function finish(flag) {");
nwf.document.writeln("var widget =
window.opener.document.getElementById(id1);");
nwf.document.writeln("widget.value = '' + " + cnt + ";");
nwf.document.writeln("if (flag)
window.opener.document.getElementById(id2).click() ;");
nwf.document.writeln("else window.close();");
nwf.document.writeln("}");
nwf.document.writeln("</SCRIPT>");
nwf.document.writeln("<TITLE>recursive javascript</TITLE></HEAD>");

nwf.document.writeln("<BODY BGCOLOR=silver ><FORM><CENTER>");
nwf.document.writeln(teststr + "<BR><BR>");
nwf.document.writeln("<INPUT TYPE=BUTTON VALUE=repeat
onclick='finish(1)'><BR><BR>");
nwf.document.writeln("<INPUT TYPE=BUTTON VALUE=close
onclick='finish(0);'><BR><BR>");
nwf.document.writeln("</CENTER></FORM>");
nwf.document.writeln("</BODY></HTML>");
nwf.document.close();
}

*** recurse.html ***

<HTML><HEAD>
<SCRIPT LANGUAGE='JavaScript1.2' SRC='fc.js'></SCRIPT>
<TITLE>Test</TITLE></HEAD>
<BODY><FORM><CENTER>
<INPUT TYPE=TEXT SIZE=8 NAME='I0' ID='I0' VALUE=1>
<SPAN STYLE={visibility:hidden}>
<INPUT TYPE=BUTTON ID='I1' NAME='I1' VALUE='' onclick='testrut("I0",
"I1");'> </SPAN>
<INPUT TYPE=BUTTON VALUE='start' onclick='testrut("I0", "I1");'>
</CENTER></FORM></BODY></HTML>
Jul 23 '05 #2

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

Similar topics

6
by: Jon Maz | last post by:
Hi All, I am experimenting with URL Rewriting using the techniques outlined by Scott Mitchell in his article "URL Rewriting in ASP.NET"...
3
by: Jamie Jackson | last post by:
I'm rewriting all links' onclick events, but I'm having a problem. The onclick event that I'm inserting works correctly in Opera, but not in FF or IE. I'm retroactively adding the statement...
2
by: Jon Maz | last post by:
Hi All, I've been looking into options for URL Rewriting in .net, and to be honest, I haven't seen anything that's easier than the old Classic Asp solution with an ISAPI filter redirecting to an...
3
by: Michael Appelmans | last post by:
I'm trying to use a rule based URL rewrite application which uses HttpApplication.RewritePath. I keep getting "rsource not found" error in application when running on shared web host although the...
2
by: R-D-C | last post by:
Can these two functions coexist? We have a web site where the querystrings are removed using URL Rewriting. Instead the page appears to be a html page with a long name (containing what would be...
0
by: Lee | last post by:
Hi all ;) Preamble -------- I'm using URL rewriting to enforce a frames policy (yeah, I know frames are 'bad' :) - i.e. if a request comes in for a page which should be nested within a...
0
by: darrel | last post by:
I'd like to move towards implementing a URL rewriting system for our CMS. I've been reading a lot about doing it with .net, itself, but have come to the conclusion that this is really something...
3
by: Greg Collins [Microsoft MVP] | last post by:
I have done a bit of research of Url Rewriting, but as yet have been unsuccessful at getting it to work well, and there are issues around what file types are supported and how much code you want to...
9
by: Frankie | last post by:
I understand that with URL rewriting we can have a request come in for, say Page1.aspx, and rewrite it so that PageA.aspx gets served up to the user. My question (assuming the above is correct):...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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,...

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.