/    Sign up×
Community /Pin to ProfileBookmark

writing JS call to NewWindow.document.write

hello!
well i have a function that recieves 3 parameters, the title -> Title, a file -> PGN and a name -> NAME
but i want to add a 4th parameter which is CONDITION.
now i want CONDITION to be the name of a text file, and in the new window the user to be able to click on a link and open the CONDITION file.
something like:

[CODE]function OpenWindow(TITLE,NAME,PGN)
{
var NewWindow=window.open(”,’name’,’height=660,width=650,status=1′);

NewWindow.document.write(‘<html><head><title>’ + TITLE + ‘</title>’);
NewWindow.document.write(‘</head><body background=”bakgrnd2.jpg”>’);
NewWindow.document.write(‘<script type=”text/javascript” src=”../../scripts/condiciones.js”></script>’);
NewWindow.document.write(‘<H2><FONT COLOR=”Maroon”>’ + NAME + ‘</FONT></H2>’);
NewWindow.document.write(‘<a href=”javascript:Condiciones(‘condicion.txt’)”>purefan</a>’);
NewWindow.document.write(‘<APPLET code=”ChessBoard.class” align=”baseline” width=”630″ height=”560″>’);
NewWindow.document.write(‘<PARAM name=pgngamefile value=’ + PGN + ‘>’);
NewWindow.document.write(‘</APPLET>’);
NewWindow.document.write(‘<br><a href=’ + PGN + ‘>download the PGN</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;’);
NewWindow.document.write(‘<a href=”javascript:self.close()”>close this window</a></p>’);
NewWindow.document.write(‘</body></html>’);
NewWindow.document.close();
}
//–>
</script>[/CODE]

being condiciones.js:

[CODE]function Condiciones(FILE)
{
var VentanaCondicion = window.open(”,’name’,’height=440,width=900,status=1′);
VentanaCondicion.document.write(‘<html><frameset cols=”100%” border=”0″>’);
VentanaCondicion.document.write(‘<frame name=”left” src=” ‘ + FILE+ ‘” marginwidth=”0″ marginheight=”0″ scrolling=”auto” frameborder=”0″ noresize>’);
VentanaCondicion.document.write(‘</frameset><body>’);
VentanaCondicion.document.write(‘</body></html>’);
}
<!– this is the best way i could find to display the FILE file. i know its lame 🙁 –>
[/CODE]

the problem surges in the line:

[code] NewWindow.document.write(‘<a href=”javascript:Condiciones(‘condicion.txt’)”>purefan</a>’);[/code]

Just to make things clear, i dont want to always display ‘condicion.txt’, this is the file i want to change with the paremeter CONDITION but for testing purposes i set the file as is.
back on track, for the displayed line, if i write:

[code] NewWindow.document.write(‘<a href=”javascript:Condiciones(‘condicion.txt’)”>purefan</a>’);[/code]

it says [B]object expected[/B] and if i write:

[code] NewWindow.document.write(‘<a href=”javascript:Condiciones(“condicion.txt”)”>purefan</a>’);[/code]

it says [B]syntax error[/B].

as a final note:
i would like my function to be:

[code]
function OpenWindow(TITLE,NAME,PGN, CONDITION)
{
var NewWindow=window.open(”,’name’,’height=660,width=650,status=1′);

NewWindow.document.write(‘<html><head><title>’ + TITLE + ‘</title>’);
NewWindow.document.write(‘</head><body background=”bakgrnd2.jpg”>’);
NewWindow.document.write(‘<script type=”text/javascript” src=”../../scripts/condiciones.js”></script>’);
NewWindow.document.write(‘<H2><FONT COLOR=”Maroon”>’ + NAME + ‘</FONT></H2>’);
NewWindow.document.write(‘<a href=”javascript:Condiciones(‘ ‘ + CONDITION + ‘ ‘)”>purefan</a>’);
NewWindow.document.write(‘<APPLET code=”ChessBoard.class” align=”baseline” width=”630″ height=”560″>’);
NewWindow.document.write(‘<PARAM name=pgngamefile value=’ + PGN + ‘>’);
NewWindow.document.write(‘</APPLET>’);
NewWindow.document.write(‘<br><a href=’ + PGN + ‘>download the PGN</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;’);
NewWindow.document.write(‘<a href=”javascript:self.close()”>close this window</a></p>’);
NewWindow.document.write(‘</body></html>’);
NewWindow.document.close();
}
//–>
</script>[/code]

or at least thats the idea.
I hope i explained myself right…im not sure i did :p
Anyways thanks for your time and all ?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@bathurst_guyAug 29.2005 — [CODE]
function OpenWindow(TITLE,NAME,PGN, CONDITION)
{
var NewWindow=window.open('','name','height=660,width=650,status=1');

NewWindow.document.write('<html><head><title>' + TITLE + '</title>');
NewWindow.document.write('</head><body background="bakgrnd2.jpg">');
NewWindow.document.write('<script type="text/javascript" src="../../scripts/condiciones.js"></script>');
NewWindow.document.write('<H2><FONT COLOR="Maroon">' + NAME + '</FONT></H2>');
NewWindow.document.write('<a href="javascript:Condiciones('' + CONDITION + '')">purefan</a>');
NewWindow.document.write('<APPLET code="ChessBoard.class" align="baseline" width="630" height="560">');
NewWindow.document.write('<PARAM name=pgngamefile value=' + PGN + '>');
NewWindow.document.write('</APPLET>');
NewWindow.document.write('<br><a href=' + PGN + '>download the PGN</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
NewWindow.document.write('<a href="javascript:self.close()">close this window</a></p>');
NewWindow.document.write('</body></html>');
NewWindow.document.close();
}
//-->
</script>
[/CODE]
Copy linkTweet thisAlerts:
@purefanauthorAug 29.2005 — Thank you very much! i worked as i needed ?
×

Success!

Help @purefan spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...