Wrox Programmer Forums
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 3rd, 2005, 08:39 AM
Authorized User
Join Date: Jun 2003
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?


Old June 8th, 2005, 01:09 AM
Registered User
Join Date: Jun 2005
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>

Old June 8th, 2005, 04:34 AM
joefawcett's Avatar
Wrox Author
Join Date: Jun 2003
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)

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

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