Jump to content

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


Recommended Posts

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:

[code]

function submital() {

x = "";

x = document.ans.text.value;

x = x.toLowerCase();

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

}
[/code]

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.
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?
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.com/Technologies/ecmaScript/quickref/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.

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.
[code]
<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>
[/code]

I assume that the user enters google on the textbox and not anything else like google.com or www.google.com
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.