Closed Bug 263201 Opened 20 years ago Closed 20 years ago

Wrong code interpretation in my page; when I open new window and fill it with 'document.write()' function; Another JavaScript code in the window work strange...

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: feaber, Assigned: bugzilla)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20040913 Firefox/0.10.1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20040913 Firefox/0.10.1

THIS IS THE CODE:
========================
========================
function OpenIMGWindow()
{
	var okno = open('','', 'width=700,height=500');
	var ToWrite;

	// Begin
	ToWrite = '<html><head><title>::TITLE::</title></head>';	

	// Java Script's
	ToWrite += '<SCRIPT language="JavaScript">';
	ToWrite += 'var aImg = new Array(';

		//Put some images here !!
		ToWrite += '\'../../gfx/load.png\',';
		ToWrite += '\'../../gfx/load2.png\',';
		ToWrite += '\'../../gfx/load3.png\',';
		ToWrite += '\'../../gfx/load4.png\',';
		ToWrite += '\'../../gfx/left.png\',';
		ToWrite += '\'../../gfx/right.png\',';
		ToWrite += '\'../../gfx/start_img01.jpg\',';
		ToWrite += '\'../../gfx/prawygorny.png\');';

	ToWrite += 'var	CurrPic='+CurrPicNum+';';

	ToWrite += 'function ChangeIMG(What,ToWhat) {if (CurrPic != What)
document.images[What].src=ToWhat;}';

	ToWrite += 'function next() {';
	ToWrite += 'CurrPic++;if(CurrPic>'+(NumPic-1)+'){CurrPic=0;}';
	ToWrite += 'ChangeIMG(\'picMain\',aImg[CurrPic]);';
	ToWrite += '}';

	ToWrite += 'function back() {';
	ToWrite += 'CurrPic--;if(CurrPic<0){CurrPic='+(NumPic-1)+';}';
	ToWrite += 'ChangeIMG(\'picMain\',aImg[CurrPic]);';
	ToWrite += '}';

	ToWrite += 'function Init() {';
	ToWrite += 'ChangeIMG(\'picMain\',aImg[CurrPic]);';
	ToWrite += '}'

	ToWrite += 'function SetXImg(i) {';
	ToWrite += 'ChangeIMG(\'picMain\',aImg[i]);';
	ToWrite += 'CurrPic= i;';
	ToWrite += '}'

	ToWrite += '</SCRIPT>';	
	
	// Body
	ToWrite += '<body bgcolor="#44aaff" onLoad="Init()">';
	ToWrite += '<TABLE BORDER="1" WIDTH="100%" HEIGHT="100%" CELLSPACING="0"
CELLPADDING="0">';
	ToWrite += '<tr HEIGHT="95%"><td><center>';
	ToWrite += '<img src="../../gfx/load.png" name="picMain">';
	ToWrite += '</center></td></tr>';
	ToWrite += '<tr><td><center>';

	ToWrite += '<a href="JavaScript:void(null)" onClick="back()">';
	ToWrite += '<img src="../../gfx/left.png" border="0"></a>';

	ToWrite += '<SCRIPT language="JavaScript">';
	ToWrite += 'var i=0;';
	ToWrite += 'document.open();';
	ToWrite += 'document.write(\' | \');';
	ToWrite += 'for(i=0; i<'+NumPic+';i++){';
	
	ToWrite += 'document.write(\'<a href="javascript:void(null)"'; 
	ToWrite += 'onClick="SetXImg(';
	ToWrite += '\'+i+\'';
	ToWrite += ');">';
	ToWrite += '\'+(i+1)+\'';
	ToWrite += '</a>\');';

	ToWrite += 'document.write(\' | \');';
	
	ToWrite += '}';
	ToWrite += 'document.close();';
	ToWrite += '</SCRIPT>';

	ToWrite += '<a href="JavaScript:void(null)" onClick="next()">';
	ToWrite += '<img src="../../gfx/right.png" border="0"></a>';

	ToWrite += '</center></td></tr></table>';
	ToWrite += '</body>';	
	
	// End
	ToWrite += '</html>';						

	okno.document.open();
	okno.document.write(ToWrite);
	okno.document.close();
}

========================
========================

Ok. So I have wirtten a function, and It should open a new window for Big Imgaes
(I makeing gallery). And this function should write other code to fill the new
Window ('document.write()'). I have used some JavaScript's, and it didnt work. I
tryed it in InternetExplorer 6.0 and there was all right. In FireFox, page in
Window have infinity loading.

I find there another problem. If I add some CSS support ('LINK' tag in 'head',
the page will not load at all.

And if I try to REFREASH the Window, all pictures disapears, and the part of
code that I write in JavaScript ('for' loop) is inserted (double) at bottom of
all code that should be created by my function (try to analize code when you see
the page CTRL+U)

PS: Sorry for my English :)
feaber@tenbit.pl

Reproducible: Always
Steps to Reproduce:
1. Write code
2. Open page
3. (optional push F5 - you will get even bigger mess :P )

Actual Results:  
My page look's bad :)

Expected Results:  
GEKO? meaby there is something wrong... I dont know...

[none]
Did you upload your page so we can look at it ?
Severity: blocker → normal
(In reply to comment #1)
> Did you upload your page so we can look at it ?

No, I didnt. But I can give you all my page via email...
setting ->INVA
the script was trying to do something illegal.
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.