473,795 Members | 2,830 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Set/Navigate to a Location (what is the correct way?)

Hi all,

This may sound real strange, but I'm curious what the "official"
answer is.

In my JS, I want to redirect/navigate to a url...

In Mozilla,

document.locati on.href = '{my_url}'; //works in Moz, IE6, IE7, Opera,
etc.

window.location .href = '{my_url}'; //works in Moz, IE6, IE7, Opera,
etc.

But.... there are times, in IE6, when...

document.locati on.href = '{my_url}';

does *NOT* work... and IE just ignores the request...

Now, from all the specs I read, it looks like location.href was only
ever intended to be read-only... but browsers seemed to make it
editable... and in IE6, document.locati on.href( '{my_url}' ); even
works (sometimes), because MS added this ability because so many were
trying it, finding it not to work, and submitting bugs...
So, 2 questions...

1.) What is the "official" way to set the page location (e.g. to some
other page)
2.) If document.locati on.href is fine, anyone know why IE sometimes
ignores it, when it is set to a new value?

Apr 13 '07 #1
3 8798
st************* *@gmail.com wrote:
Hi all,

This may sound real strange, but I'm curious what the "official"
answer is.

In my JS, I want to redirect/navigate to a url...

In Mozilla,

document.locati on.href = '{my_url}'; //works in Moz, IE6, IE7, Opera,
etc.

window.location .href = '{my_url}'; //works in Moz, IE6, IE7, Opera,
etc.

But.... there are times, in IE6, when...

document.locati on.href = '{my_url}';

does *NOT* work... and IE just ignores the request...

Now, from all the specs I read, it looks like location.href was only
ever intended to be read-only... but browsers seemed to make it
editable... and in IE6, document.locati on.href( '{my_url}' ); even
works (sometimes), because MS added this ability because so many were
trying it, finding it not to work, and submitting bugs...
So, 2 questions...

1.) What is the "official" way to set the page location (e.g. to some
other page)
2.) If document.locati on.href is fine, anyone know why IE sometimes
ignores it, when it is set to a new value?
"document.locat ion" is deprecated, use "document.U RL" or "location.h ref"
or "window.locatio n.href"
Mick
Apr 13 '07 #2
In comp.lang.javas cript message <46************ ***********@roa drunner.co
m>, Fri, 13 Apr 2007 18:00:09, Michael White <mi**@mickweb.c omposted:
>"document.loca tion" is deprecated, use "document.U RL" or
"location.href " or "window.locatio n.href"
A <FAQENTRYon "Deprecated " might well be useful, though it would need
to be backed up by a Web page.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demo n.co.uk/- FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "" (SonOfRFC1036)
Apr 15 '07 #3
I'm not sure what happened to the begining of this thread, but I
figured out what was happening.

In IE6 only, if you have a link (change square brackets for angled)

[a href="javascrip t:;" onclick="doSome thing"]Click Me[/a]

and...

[script]
function doSomething(){
document.locati on.href = 'http://www.example.com/';
}
[/script]
It won't work.. well, kind of. It actually does the HTTP GET request,
on "example.co m", but the original page never leaves the screen, the
"flag" in the corner doesn't wave, and the progress bar only flashes
for a few milliseconds. As far as the user sees it, nothing happened.
(even the history of visiting this link is not stored)

Its like 1/2 AJAX in IE6, without the ActiveX, and without the
postback.


On Apr 15, 12:23 pm, Dr J R Stockton <jr*@merlyn.dem on.co.ukwrote:
In comp.lang.javas cript message <46************ ***********@roa drunner.co
m>, Fri, 13 Apr 2007 18:00:09, Michael White <mi**@mickweb.c omposted:
"document.locat ion" is deprecated, use "document.U RL" or
"location.h ref" or "window.locatio n.href"

A <FAQENTRYon "Deprecated " might well be useful, though it would need
to be backed up by a Web page.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demo n.co.uk/- FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "" (SonOfRFC1036)

Apr 15 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
14739
by: Scott | last post by:
I'm new to ASP, but I've been programming in VB for several years, and I'm having a few issues with this ASP enhancement I'm working on. I've found ASP to be a lot different than what I'm use to in VB. I've created an ASP interface where a user can select an email group that populates a listbox with those email addresses. If a user sees an email in that list that they do not want then they can remove it by clinking the Delete button...
2
10406
by: Boyd | last post by:
Hello All, I have a dropdown on a page (contact_us.asp) that when it is changed the page reloads and displays the contact details selected, to do this i have a onChange() running on the dropdown and that runs a function in my javascript. All the JS function is: function OfficeChange()
2
7644
by: djozy | last post by:
Please I have dropdownlist on my web form. I would like to get web page from url adress automaticly, when I select one of the items in dropdownlist. I have put autopostback property of dropdownlist to true. Is there any way to get url adress using normal buttons, or like in this case, list controls instead using only hyperlink Thank you
1
1460
by: Mikael Syska | last post by:
Hi, I want to navigate though my usercontrols via some buttons, how to i do that.... I have tried lots of thing, but as I'm still new to C# i havent found the right path to follow yet, are there any one that can help me, I have the following code.... private void Form1_Load(object sender, System.EventArgs e)
1
1880
by: Linda Wienholt | last post by:
Hi I am trying to link to a specific location on a page using a named anchor. I also have some parameters attached to the query string. I am having problems getting the page to display the correct portion of the page when it loads I have a few named anchors on the page using the following format <a name="branding"></a>Then some text here. In the URL I have http://mysite.com.au/default.aspx?id=1#branding when I load this page it does...
5
3979
by: Jeronimo Bertran | last post by:
I have an <a href=url> inside an Iframe.... when I click it, the url is navigated inside the frame... what do I need to do in order to navigate the url on the browser window and NOT the iframe?? Thanks , Jeronimo
1
1795
by: lorents | last post by:
hello i have this small code: <? if ($errorsTable == 0) { ?> <script type="text/javascript"> window.navigate("main.php"); </script> <?
2
1466
by: =?Utf-8?B?UmljaGFyZA==?= | last post by:
Hello, How are the following ways to navigate the site different? Why are there so many to do the same thing? Which one is best to follow? window.href.location = "..." Server.Transfer("...") Response.Redirect("...")
5
23452
by: timnels | last post by:
I have a web browser control that I'd like to point at a HTML file in my installation directory. I am doing something like: string path = Path.GetDirectoryName( Assembly.GetExecutingAssembly().GetModules() .FullyQualifiedName) + "\\howdoi.htm"; webBrowser1.Navigate(path); What do I need to do to form the correct URI string for a local file?
0
10216
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10165
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10002
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7543
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6783
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5565
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2921
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.