Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
|
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 August 5th, 2005, 02:12 PM
Friend of Wrox
 
Join Date: Apr 2004
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
Default Open Window and Write HTML to Child Advice

I am looking to open a new window and write html to that window. The problem I am having is that I need the body tag to have an onload event fire in the new window. I cannot seem to get it to work.

Here is the code that I am using...

function vidopen()
{
    var newWindow = window.open("","vidwindow");
    newWindow.document.writeln("<head><script language='VBScript' src='3init.vbs'></script><script language='VBScript' src='3web.vbs'></script><script language='VBScript' src='3score.vbs'></script></head><body onLoad='vbscript:LaunchVideo(%22na_pref%22)'></body>");
}

Any thoughts?

Clay Hess
__________________
Clay Hess
 
Old August 6th, 2005, 03:01 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Your quotes seem to be wrong. It should be:
Code:
body onLoad='vbscript:LaunchVideo(\"%22na_pref%22\")'>
You shouldn't put the protocol in an event handler attribute but it probably won't hurt. I presume yhou know using VBScript will make it IE only.

The second thing to do is add the "defer" attribute to the script block, preferably the one that has the handler but it wont hurt on the others:
Code:
<script language='VBScript' src='3init.vbs' defer>
--

Joe (Microsoft MVP - XML)
 
Old August 6th, 2005, 10:53 AM
Friend of Wrox
 
Join Date: Apr 2004
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the tip.

I tried what you suggested, but it did not work. Any other thoughts?

Clay Hess
 
Old August 6th, 2005, 02:04 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Perhaps add the html tags. You should also close the document:
Code:
newWindow.document.write(....);
newWindow.document.close();
--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Closing parent window from child window arnabghosh Javascript How-To 1 December 26th, 2007 01:18 AM
closed parent window when opened child window jaiwin Javascript How-To 0 October 8th, 2006 12:54 PM
Print html page using window.open manish.sharma04 BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 0 April 1st, 2006 03:20 AM
response.write open link in new window netcrawler Classic ASP Basics 10 October 25th, 2004 07:42 AM
Close Parent window on opening child window pkdev Javascript How-To 8 April 11th, 2004 12:06 PM





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