Jump to content


Photo

use JS to go to a link with out window.open's new window


  • Please log in to reply
5 replies to this topic

#1 jsam

jsam
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 10 September 2006 - 03:39 PM

i'm getting input from people and taking them to a webpage, but the only way i know to do this is with window.open. i want to have the same functionality but instead of a new window, i want the page to load in the same window instead of openning a new one.

an example would be:


	function submital() { 

	x = "";	
 
	x = document.ans.text.value;

	x = x.toLowerCase(); 

	window.open(x + '.htm');

	}

this obviously opens a new page. i want the same functionality (i.e., be able to get info from my form and use that in the "submital" function), but without the new window.

thanks for any help.

#2 radalin

radalin
  • Members
  • PipPipPip
  • Advanced Member
  • 179 posts

Posted 10 September 2006 - 03:55 PM

window's open method was an overloaded one as I remember. You can define to open in a new window or not. There was something around in this forum.

By the way you try document.location = x + ".htm" instead of window.open()
Roy Simkes
Yet Another Parkyeri Developer

#3 jsam

jsam
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 10 September 2006 - 04:11 PM

i tried to use document.location (and document.location.href) and neither seems to do what i want it to (in fact, both just sit there). i'm still searching around the forum to find where they said how to use window.open and opt to not open a new window...

any more help?

#4 radalin

radalin
  • Members
  • PipPipPip
  • Advanced Member
  • 179 posts

Posted 10 September 2006 - 04:36 PM

Seems that I have mistaken about that. window.open will create a new window. Here is a quick search from google and what I have found

http://www.devguru.c...f/win_open.html

do you try to redirect someone to a domain outside of yours then you should add http:// before.

<script language="javascript">document.location = "http://www.google.com"; </script>

works ok by the way.


Roy Simkes
Yet Another Parkyeri Developer

#5 jsam

jsam
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 10 September 2006 - 04:44 PM

ok, so i know i'm pathetic at javascript...
could you use the "google" example such that if a person entered "google" into the form and hit "submit," google would enter in the same window. i can't seem to get this to work for me, but i'm sure it's just my scripting shortcoming.

#6 radalin

radalin
  • Members
  • PipPipPip
  • Advanced Member
  • 179 posts

Posted 10 September 2006 - 04:52 PM

<form name="frm1">
<input type="text" name="destination" id="destination" />
<input type="button" value="Get me the link" onSubmit="document.location = 'http://www.' + destination.value + '.com' ;" /> 
</form>

I assume that the user enters google on the textbox and not anything else like google.com or www.google.com
Roy Simkes
Yet Another Parkyeri Developer




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users