Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
  1. #1
    Banned
    Join Date
    Oct 2008
    Posts
    1
    Member #
    17548
    Hi, I am just learning javaScript, and I need to do a Webpage urgently, a new window will open up when we click on them. I wrote a code acording to my best knowledge, been trying to correct it for days and it juxt does not work. Can anyone help? I have kitchen0.html that I would like to open, I put idó"img0" to the image link in the html file. The browser said there is an error on the page.The code I wrote:
    window.onload = initAll;
    function initAll(){
    document.getElementById("img0").onclick = newWindow;
    }
    function newWindow(){
    var imgWindow = window.open(kitchen.html,"imgWin", "width=400, height=300, scrollbars=0");
    }
    Please can anyone help!!!!

  2.  

  3. #2
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    The error you are probably having is that img0 is not defined yet. What browser did you test this page with? I suggest using a browser named Firefox, it's error console is very good.

    Try the below code.

    HTML Code:
    <html>
    
    <head>
    
    	<title>JS test</title>
    
    	<script type="text/javascript">
    
    	function newWindow()
    	{
    		var imgWindow = window.open('kitchen.html',"imgWin", "width=400, height=300, scrollbars=0");
    	}
    
    	</script>
    
    </head>
    
    <body>
    
    	<div id="img0" onclick="javascript: newWindow();">Click me</div>
    
    </body>
    </html>

  4. #3
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    What error does the browser say there is? If you're in IE, double-click on the little warning symbol in the bottom right. If you're in Firefox, click Tools->Error Console. You should be able to get some info about the error that happened. Not a particularly useful one in IE, in general, but at least some pointer as to where it is.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:16 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com