473,396 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

onpropertychange event is not fired when you change document location

Hello ,

I have attached the onpropertychange event to my document as :



Expand|Select|Wrap|Line Numbers
  1. // the handler function 
  2.  
  3. function propertychangeHandler(){
  4.  
  5. alert('propertychange event...');
  6.  
  7.  
  8. document.onpropertychange=propertychangeHandler;
  9.  
  10.  
  11. // now, when I change the document.location as :
  12.  
  13. document.location="http://www.google.com";
  14.  
the event is not fired, it doesn' t call the handler .
I read the documentation of msdn that this event is applied to document object .


I have IE7 on Window Vista on my machine .


any suggestion ?

thanks ,
Mar 11 '08 #1
7 4142
acoder
16,027 Expert Mod 8TB
If you're trying to detect when the page changes, just use onbeforeunload instead.
Mar 12 '08 #2
mrhoo
428 256MB
document.location is a read only string, now deprecated in favor of document.URL

You can't change the url of a document with javascript- only the url that is loaded in window.location, which is apparently what IE is doing.
Mar 12 '08 #3
If you're trying to detect when the page changes, just use onbeforeunload instead.
Ok , but do you think I can catch what the url being assinged to document.location inside the onbeforeunload handler ?

if you look at my example , document.location = "http://www.google.com".
could I know that my document will be overwritten by http://www.google.com ?

thanks .
Mar 13 '08 #4
document.location is a read only string, now deprecated in favor of document.URL

You can't change the url of a document with javascript- only the url that is loaded in window.location, which is apparently what IE is doing.
if I understood you, simply in javascript you can say :
document.location = "http://example.com".

this is an assigment, so document.location is read/write property !!

in any case, and same for the window.location = "http://www.example.com".
why the onpropertychange event is not fired !!

could you please explain more .

thanks .
Mar 13 '08 #5
mrhoo
428 256MB
document.location is no longer a property of the document.URL, but an alias for the window's location object.

When you write to it, you are not changing the url of the document-
you are changing the window location to the url of another document .
Mar 13 '08 #6
document.location is no longer a property of the document.URL, but an alias for the window's location object.

When you write to it, you are not changing the url of the document-
you are changing the window location to the url of another document .
ya, that's clear , thanks very much .
Mar 13 '08 #7
acoder
16,027 Expert Mod 8TB
Ok , but do you think I can catch what the url being assinged to document.location inside the onbeforeunload handler ?

if you look at my example , document.location = "http://www.google.com".
could I know that my document will be overwritten by http://www.google.com ?

thanks .
That would be window.location.href. I'm not sure if you can, but I doubt it. Why do you need to know what the URL of the next page is?
Mar 13 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Alistair Saldanha | last post by:
I'm looking for the event that is fired by Internet Explorer to an "alert": <SCRIPT> Alert("You already have a session open") </SCRIPT> The event would be webBrowser.Document.???? Much...
0
by: Miquel | last post by:
Hi all. I felt frustrated when developing an 'UserControl' derivated from textBox, because sequence event (and Validate event) seems to fail. I Always thought my code was wrong. But after...
1
by: Bin Song, MCP | last post by:
Hi all I got a strange problem In my webform, I have a server-side Button "btnDisable" to save some data and enable or disable all other fields in this form based on the data. The logic is: on...
7
by: sunil philip | last post by:
How do i identify the page that fired a method? e.g. page1.html ----------- <Head> <script> document.write(myfun()); </script>
0
by: Gary Shell | last post by:
I am experiencing some strange behavior between a UserControl's validating event and a treeview control. Initially, I thought it was related to an issue in the Knowledgebase article 810852...
6
by: pronerd | last post by:
Hi, I am trying to dynamically set an event handler across frames. I have no problems setting properties across frames doing something like parent.ToolMenuFrame.location.href =...
5
by: jaysonnward | last post by:
Hello All: I've recently been recreating some 'dropdown menus' for a website I manage. I'm writing all my event handlers into my .js file. I've got the coding to work in Firefox, but the...
12
by: bogdang20 | last post by:
Hello, I have a piece of code written for IE that uses onpropertychange. I want to make the code work on Firefox also, but i couldnt find an equivalent event that fires when the value is changed...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.