Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 3rd, 2005, 08:39 AM
Authorized User
Join Date: Jun 2003
Location: Jewett City, CT, USA.
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default Adding javascript to popups

I have a stand-alone Flash training application that is opened as a popup from another HTML page. If the student clicks on the Windows close button, I want to have an alert telling them that they're not allowed to do that. I've been trying to add a fairly simply javascript to the popup code, but I keep getting errors saying that I have an "Unterminated string constant" on the line that reads:

Here is a portion of the code:
function openPop() {
    NFW = window.open("","popFrameless",s)
    var frameString="<html>"+
    "function checkExit() {"+
    " //Do something here
    "<body onBeforeUnload=\"javascript:checkExit()\"></body></html>"

Is there a way I can get around these errors?


Reply With Quote
  #2 (permalink)  
Old June 8th, 2005, 01:09 AM
Registered User
Join Date: Jun 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts



var windowW=214
var windowH=398
var windowX = 260
var windowY = 100
var urlPop = "http://www.yahoo.com"
var title = "PopUp Window!"
var autoclose = true

s = "width="+windowW+",height="+windowH;
var beIE = document.all?true:false
function openFrameless() {
if (beIE) {
NFW = window.open("","popFrameless","fullscreen,"+s);
var frameString=""+
"<frameset rows='*,0' framespacing=0 border=0 frameborder=0>"+
"<frame name='top' src='"+urlPop+"' scrolling=auto>"+
"<frame name='bottom' src='about:blank' scrolling='no'>"+
else {
NFW = window.open(urlPop,"popFrameless","scrollbars,"+s) ;
if (autoclose) {
window.onunload = function(){NFW.close();}



<BODY onLoad="top.window.focus()">

<a href="javascript:openFrameless()">Click Here</a>

Reply With Quote
  #3 (permalink)  
Old June 8th, 2005, 04:34 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts

When writing script via a string you break up the script word to prevent confusing the parser:
"<script>" ... "</script>"
"<scr" + "ipt>" ... "</scr" + "ipt>"
I believe it's not necessary for both but I do it anyway as I can never remember which one...


Joe (Microsoft MVP - XML)
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
adding checkbox to datagrid using javascript k.manisha ASP.NET 1.0 and 1.1 Professional 0 June 4th, 2007 11:02 PM
adding items to list box using javascript k.manisha ASP.NET 1.0 and 1.1 Professional 3 February 16th, 2007 06:32 AM
adding php code in javascript chayanvinayak Javascript How-To 2 December 18th, 2006 02:33 AM
POPUPS venks11 Classic ASP Basics 1 December 6th, 2005 06:56 AM
adding a class in JavaScript crmpicco Javascript How-To 5 October 4th, 2005 08:15 AM

All times are GMT -4. The time now is 10:06 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.