![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jun 2005
Posts: 29
Rep Power: 0
![]() |
popup
i'm struck at this place,.. couldnt solve this problem. guys need your help. thanks. i couldnt make the window pop up..
<html> <head><SCRIPT LANGUAGE="JavaScript"> <!-- function reportCard() { var header = ("<html><head><title></title></head>"); var body = ("<body>Helloworld</body>"); var footer = (</html>); var pageBody = ("" + header + "" + body + "" + footer + ""); reportWin = window.open("","","width=620,height=400,toolbar=yes,menubar=yes,scrollbars=yes"); reportWin.document.write(pageBody); reportWin.document.close(); //reportWin.document.write(pageBody); //reportWin.document.close(); } --> </script> </head> <body> <form method="post"> <INPUT TYPE="button" VALUE="Report Card" onClick=reportCard(this)> </form> </body></html> |
|
|
|
|
|
#2 |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
<html> <head><SCRIPT LANGUAGE="JavaScript">
<!--
function reportCard() {
var header = ("<html><head><title></title></head>");
var body = ("<body>Helloworld</body>");
var footer = (</html>);
var pageBody = ("" + header + "" + body + "" + footer + "");
reportWin = window.open("","","width=620,height=400,toolbar=yes,menubar=yes,scrol lbars=yes");
reportWin.document.write(pageBody);
reportWin.document.close();
//reportWin.document.write(pageBody);
//reportWin.document.close();
}
-->
</script>
</head>
<body>
<form method="post">
<INPUT TYPE="button" VALUE="Report Card" onClick=reportCard(this)>
</form>
</body></html>2.That is an error. You're missing quotation marks. 3. You don't need to put emptry strings next to each when you're concatanating. You can just do `var pageBody = header + body + footer` 4. No spacing there. 5. I'm fairly sure you can't just open a window and call win.document.write. You'll probably need to open a new window, append a body element, and then use innerHTML to generate the content on the fly. 6. You should be doing `onclick="reportCard()"`, not reportCard(this) as the reportCard function does not take a parameter. That won't raise an error, however. |
|
|
|
|
|
#3 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Cerulean's recollection on point 5 is correct. Here's a working piece of code that generates a popup with a specific message. Obviously, the variable, "cred", could be an argument and dynamically stuffed with whatever you like.
function credits ()
{
var cred;
var credWin;
var specWin;
cred = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link rel="stylesheet" type="text/css" href="dawei.css"><title>Credits</title></head><body><div style="background-image: url("images/paper.jpg"); padding: 50px 50px 50px 50px; border: 2px solid #000000;"><table border="0"><tr><td><h3><center>Credits</center></h3></td></tr><tr><td align="left">Thanks to all the DevShed C/C++ forum members for their suggestions and for contributing to the correctness of the material.<p>A special thanks to Grumpy and Infamous, Grumpy for the time he spent in attempting to promote clarity as well as accuracy; Infamous for his suggestions "from the viewpoint of a n00b" and particulary for his suggestion that I add a few definitions that show via flyout when moused over.</p><p>I unashamedly ripped and adapted some presentational thangys from Scorpions4ever\'s tutorial on <a href="http://www.mayukhbose.com/tutorials/overloading/">overloading operators</a>, which I highly recommend.</td></tr></table></div></body></html>';
specWin = "width=700,height=450,top=30,left=30," +
"screenx=30,screeny=30," +
"resizable=yes,scrollbars=yes";
credWin = enlarge ("", specWin);
credWin.document.write (cred);
credWin.document.close ();
}function enlarge (wURL, sp)
{
var specs = "width=800,height=600,top=30,left=30," +
"screenx=30,screeny=30," +
"resizable=yes,scrollbars=yes";
if (sp) specs = sp;
popWin = open (wURL, "popWindow", specs);
popWin.focus ();
return popWin;
}
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|