[SOLVED] Javascript problem

This is a discussion on "[SOLVED] Javascript problem" within the JavaScript Forum section. This forum, and the thread "[SOLVED] Javascript problem are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jan 24th, 2008, 00:58
New Member
Join Date: Dec 2007
Location: England
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy [SOLVED] Javascript problem

Heya - I'm sorry to bother you, but I'm wondering if someone can help me out.

I managed to code the following tester page using a tutorial and editing it:
HTML: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><title>Alert Test</title>
<script type="text/javascript">
<!--
function confirmation() {
    var answer = confirm("You are now leaving this site" + '\n' + " and entering a search site")
    if (answer){
        alert("Bye bye!")
        window.location = "http://www.google.com"; 
    }

}
//-->
</script>
</head>
<body>
<form>
<input type="button" onclick="confirmation()" value="other site">
</form>
</body>
</html>
I've linked to it here http://www.sorchajane.co.uk/alertboxtest3.html

What I'm trying to do is to make the "google" link open in a new window. At the moment, it just opens in the same one. Is this even possible? I feel really stupid and embarrassed by this.

Also instead of using the form and button approach, is it possible to use images and if so, would the image need to be in a form?

Any help would be greatly appreciated.

Thanks in advance
Popje

Last edited by Rakuli; Jan 24th, 2008 at 02:39. Reason: Added some [html] bbc tags
Reply With Quote

  #2 (permalink)  
Old Jan 24th, 2008, 02:43
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Javascript problem

The answer to both of your questions is yes. You want to use the window.open('urlhere', 'windowname') function. You can add onclick to an image also to acheive the same thing.

example

HTML: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><title>Alert Test</title>
<script type="text/javascript">
<!--
function confirmation() {
    var answer = confirm("You are now leaving this site" + '\n' + " and entering a search site")
    if (confirm("A new window will open with Google")){
        alert("Bye bye!")
        window.open("http://www.google.com", 'windowName'); 
    } else {
        alert('Okay, no window then!');
     }

}
//-->
</script>
</head>
<body>
<img src="someImage.jpg" onclick="confirmation()" />
</body>
</html>
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Reply With Quote
  #3 (permalink)  
Old Jan 24th, 2008, 02:51
New Member
Join Date: Dec 2007
Location: England
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up Re: Javascript problem

THANK YOU so much!! You're a life saver. Cheers! I can finally get some sleep now.

Popje
Reply With Quote
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with JavaScript and JSP pesho318i JavaScript Forum 0 Jan 23rd, 2008 18:04
[SOLVED] Javascript tutorial hegerp JavaScript Forum 2 Nov 29th, 2007 13:31
[SOLVED] JavaScript w/flash j04155 JavaScript Forum 4 Oct 9th, 2007 13:25
[SOLVED] Javascript Ajax problem Hermanusbanken JavaScript Forum 3 Oct 2nd, 2007 14:22
Javascript problem zc1 JavaScript Forum 2 Jan 15th, 2007 17:01


All times are GMT. The time now is 22:47.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43