Capturing Domain Change Event OR Domain Of The Target URL
Jun 7, 2009
Is it possible to capture the domain change event OR domain of the target site in javascript? To elaborate, suppose I am on my site (www.mydomain.com) and if I type www.someotherdomain.com in the address bar, I want to capture the target URL/domain i.e. someotherdomain.com in the javascript code of my site (mydomain.com). I am trying to call sign-off function of my site upon customer navigation to some other site without loggin off. I can not use body/window onUnload function because I have a common layout JSP that would be reloaded for each and every page. So I am trying to capture the URL/domain of target site and check if it is different from teh current domain; Then only I will call my sign-off function to kill the customer session.
Say I'm on the site www.xyz.com and on a certain page if the user leaves the domain xyz.com, I have a popup cme up w/ stuff. I don't need to know what the new domain is, I just want to know if the user left / is leaving xyz.com.
I'm currently at http://www.domain.com/the-path.jsp, and I would like to be able, with JavaScript--and possibly the click of a button, which I will most likely attach to IE's toolbar--transport to http://domain.dev.domain.com/the-path.jsp.
Here's the environment: My browser is set to the page http://www.domain.com/the-path.jsp and I plan to add a button to IE's toolbar via the registry that I would like to execute the JavaScript, which contain the code to perform the aforementioned procedure.
My JavaScript knowledge is, as I'm sure you've already surmised, limited.
Here's what I know (or what I think I know)
The .js file header: oShell= new ActiveXObject("WScript.Shell");
the object: window.location.replace [or href].
I have a feeling a "and if" statement is needed here. Am I correct?
BTW: As far as the registry button addition is concerned, I'm set on how to do that.
I have a web site to which multiple domains point and I want to redirect to a specific subdirectory for specific domain references. I found the following script and am trying to use it but I cannot get it to work. I added the alert statements to try to see what is happening but they both retund a value of 0? Any ideas as to how I can accomplish this? Code:
Looking to set up a website which will have several different domains pointing to the same pages - different personalised branding but same content. I'd like to load a different set of style sheets based on which domain they visited the page via, and allow this setting to be remembered in a session cookie so each page they visit will continue with the same personalised style.
Had a good look around, and seen a few style switchers, but nothing which bases the switch on the domain. Anyone able to point be in the direction of a plugin or similar that would me out?
I currently use the following code to make sure that users of my form have entered the 3 basic peices of information into my form.
<script type="text/javascript"> function validate(myform) { if (!myform.name.value || !myform.email.value || !myform.msg.value) { alert('Please fill in all fields'); return false; } } </script>
Now i want to make it so if they enter a email address from a specific domain (ie @garbage.com.au) it comes up with a message saying they cannot use that domain name....
I'm having issues at the minute finding a solution to a cross domain access using the XmlHttpRequest object.
We have a site sitting on server1 whilst we have an application providing data to that site via server2 sitting on a different address. A potential solution is that when a page request is requested from server1 on address www.server1.com we can redirect the user via a HTTP 302 response to server2 for the information.
Does this still classify as cross domain access and hence the XmlHttpRequest will not work until browsers have the lowest level of security set ?? Or will this solution work fine ?
If running off of the local filesystem, in Firefox, or if the security settings are set appropriately, in Internet Exporer, XmlHttpRequests can be sent to any domain of your chosing. But what about cookies? Can cookies be accessed for any domain of your chosing?
For example, although www.domaina.tld can't access cookies for www.domainb.tld, can c: access cookies for www.domainb.tld?
The way cookies are accessed in javascript (document.cookies) would suggest not, but I just wanted to make sure.
I have a little issue with the use of jQuery and a call with the method Ajax. The problem appears with IE7 when I call just after the page was loaded. If I wait 2/3secondes, I don't have this beautiful message :
i wanna load a web page into a div tag, but the page is from another domain, its my domain but i set up a second domain for more space reasons. Now if i want to load this page into that div tag on my current domain page, how will i do so?like have[url].... with index.html and in index.html there is a div tag called "page" and when the page loads the other.html from domain2.com loads into this div tag called "page"
and i want it to show a loading.gif as like a preloader. I've googled this and got some stuff but it didn't work, and im not sure if its because of the page being in a different domain.
I wish to make an AJAX call to a script on a different domain - realise this is a security problem, but is this at all possible?
My client is embedding html web pages into his ebay listings, and he wants to centrally update the product information. Maybe there is a different / better way to go about this?
Is there ANY way to get the URL of an iframe if the page the user is on is an external domain? I know this is normally blocked by the "Same Origin Policy", but I'm just trying to find out if there is SOME workaround. All I'm trying to get is the URL.
I'm using lytebox to open an iframe, but the iframe url is in another domain that the parent window. i need to close the iframe when user clicks a button. I can do that with javascript : top.$lb.end(); the $lb.end(); starts lytebox scripts in parent window which close the iframe and modify all the css stuff. That works when my iframe url is in the same domain. But when it's in another domain, that does'nt work.
Okay, reason I say that is, its not accurate to the actual domain that the "script" is located on.
For example, domain.com has the <script url=domain2.com/jsfile> which has " document.domain " (this = domain.com)
However, if i have frame of domain3.com which frames domain.com the domain will show domain3.com but thats not what I care about, I want domain.com since thats whats actually being shown.
I am trying to extract the domain name from a url using javascript but having some problems.
This is what I have:
Code: var publisherName = document.domain; if(publisherName.indexOf('www')){ publisherName = document.domain.substr(3,document.domain.length); }
But it is not working and I am not sure how to rid of the extension Basically, this is what I want: Whether the location being sub domain or not it need to get from somthing similar to[URL]...
Is there any any ANY workaround for getting highlighted text in an iframe that is displaying a different server's site (like google for example) and storing it in a variable?I know about the Same Origin Policy, but come on. This is just highlighting text. Why can't we highlight text in an iframe?! It's the same as copy and paste, just quicker.