Communicate Between Iframes On Different Subdomains
Nov 17, 2006
Is there a way to communicate between iframes on different subdomains?
e.g. from one.dot.com to two.dot.com? there is a security access
restriction passing javascript commands between subdomains that we've
run into.
I am setting a cookie on a subdomain: http://store1.mydomain.com
Then the store takes me to a shopping cart that is at: http://shopping.mydomain.com
Somewhere the following code (taken and modified from The JavaScript Source) is broken between domains, because when I click my "store" link that should read the cookie and send me to store1.mydomain.com or storeN.mydomain.com I get the default template store.
<SCRIPT LANGUAGE="JavaScript"> <!-- Original: Ronnie T. Moore --> <!-- Web Site: The JavaScript Source -->
<!-- Begin var expDays = 30; var exp = new Date(); exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function getCookieVal (offset) { var endstr = document.cookie.indexOf (";", offset); if (endstr == -1) endstr = document.cookie.length; return unescape(document.cookie.substring(offset, endstr)); } function GetCookie (name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) return getCookieVal (j); i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } function SetCookie (name, value) { var argv = SetCookie.arguments; var argc = SetCookie.arguments.length; var expires = (argc > 2) ? argv[2] : null; var path = (argc > 3) ? argv[3] : null; var domain = (argc > 4) ? argv[4] : null; var secure = (argc > 5) ? argv[5] : false; document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } function DeleteCookie (name) { var exp = new Date(); exp.setTime (exp.getTime() - 1); var cval = GetCookie (name); document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); }
var favorite = GetCookie('store');
if (favorite != null) { switch (favorite) { case 'store1' : url = 'http://store1.mydomain.com/' break; case 'store2' : url = 'http://store2.mydomain.com/' break; case 'store3' : url ='http://store3.mydomain.com/' break; case 'storeN' : url = 'http://storeN.mydomain.com/' break; } window.location.href = url; } // End --> </script> </HEAD>
The cookie is set by a javascript "onload command" Like I said I have it working on a server with no sub domain.
I've got a situation where an already existing include file (included in various clasic .asp pages) needs to have some javascript embeded in it to detect if the user is on http: or https: This include file is used in the main domain, as well as sub domains. The "gist" of what I'm trying to do is this: header.inc (the include file included by many .asp files) used by [URL] as well as [URL], [URL], etc.
<script type="text/javascript"> if (location.protocol != "https:") { <!-- include virtual="/SSI/some_other_include_file.inc --> } </script>
Obviously, that doesn't work, but needs to have something like the include virtual because of the usage across subdomains. Basically, if the user is NOT on the secure protocol, I want to include that other file, regardless if they are on the main domain, or any of the sub domains. I've tried:
To reference another frame, you simply need to step through the frame hierarchy: `` parent '' is the page the frame is defined in, `` parent.framename '' is another frame in the same frameset. To access a variable called Moomin in a frame called Snork you would use `` parent.Snork.Moomin ''. To call the function Snufkin in that frame you would use `` parent.Snork.Snufkin() ''....
How can I use XMLHttpRequest communicate from webpage to another? Currently I have a left/right frames, when the submit button pressed (item is added to the database), the left frame should automatically retrieve this item and display it on the page.
I thought of using Ajax (XMLHttpRequest object), but not sure how to use XMLHttpRequest object in two different webpages.
I have a Flash movie on a web page and I want to send parameters to it with JavaScript to have it go to a selected frame. The AS3 code receives its information via an ExternalInterface API. The following code parses the URL argument (?page=x) and I want to send the value (x) to Flash. Unfortunately, when creating the objMovie variable, it is always undefined, therefore getFlashMovie is undefined and Flash never receives the callback. Thinking that it was because the flash movie is not loaded yet, I created a button to call callToActionscript, and when I click the button, I get the same error. (getFlashMovie("myFlashMovie") is undefined)
Also, if (params) always returns true, whether there are parameters or not. I don't understand that, either.
The code follows: <script > $(document).ready(function() { var params=getQueryParameters(); if(params) { callToActionscript(params[0]); }}); function getFlashMovie(movieName) { var isIE = navigator.appName.indexOf("Microsoft") != -1; var objMovie = (isIE) ? window[movieName] : document[movieName]; alert(objMovie); //Always return undefined return objMovie; } function callToActionscript(page) { var myMovie=getFlashMovie("myFlashMovie").sentToActionscript(page); } function getQueryParameters() { var query = window.location.href.split('?')[1]; //query won't be set if ? isn't in the URL if(!query) { return { }; } else{ var param = query.split('='); } return param[1]; } </script>
I'm trying to access a child iframe from my parent page. Is it possible? I've googled this extensively ut have found only scripts that allow me to communicate from the child iframe to the parent iframe. I want to do it the other way round. I need to be able to get in to the child frame and access it's DOM.
I am creating a website, and I have javascript function that will play a video playlist by passing it a playlist ID. I want to be able to share a url that points to my website and also calls a javascript function, like: [URL] If someone clicks/enters that url, they redirect to my website and the getPlaylist(id) function is called. Is there a way I can do this?
I have a web site. The user input is a record id. When the form is submitted, the cgi code will check if the id is in the data base, if its in the database, it will be processed, and results being displayed. If the id is not in the database, I need to pop up a window telling the user the next available id, and when the user closes the popup window, the browser should go back to the first form submit page, with the next available id in the input box.
Right now, I can pop up an alert window telling the next available id, but have no idea how to go back to the submit page when I close the alert window.
Currently, I have one of the iframes working. When you click on it text below appears with information about the jewelry.
I would like an iframe to open up (immediately to the left of the image) and show an enlarged image of the thumbnail (yes I know right now the images are not thumbnails, but my friends are working on the graphics).
I want to load a javascript file on a root page with various iframes, then call the javascript functions from the root page to be displayed in the iframes. Any idea how to do this?
I have a mainpage and it contains iframe (myFrame). A js function validatedata() is on iframe. before submitting mainform in mainpage i am calling validatedata() function as below. mybool = document.myFrame.validatedata();
This works in IE 6.0 but fails on mozilla firefox.
I have a webpage with some divs and iframes in them, I have some Javascript code in another page in one of the iframes that when activated, will change the page within the other iframe. The code I have throws the following error:
'null' is null or not an object
and it is complaning abou the following bit of code:
var obj = document.getElementById("frame2"); obj.src = new_src;
But I am not sure if the code is the correct code anyway. Can anyone assist please? Please find below my complete code, hopefully you can spot what's going on. Here is my 'index.htm' file: Code:
I'm starting to use some iframes in a div layer. I want to know if i can use javascript to change the size of the iframe (from the parent page containing the iframe).
In IE i can use 100% width and height to fit the iframe to the layer, but in Netscape 6 the iframe doesn't appear if the height is set in % values - hence the need to be able to specify it dynamically as the layer wil change size.
I am using struts frame work and in one of the jsp pages I have a bunch of IFRAMES like this.(This is in logic iterate and the recordId is incremented with that iteration) ....
I have a really professional conspiracy movie site and I use tons of layers and an external scroll bar assembly. I would like to put the various sections into MS Iframes and in order to clean up the page but I find that the iframes interfere with the getting the mouse coords from the screen which is essential in moving the scroll bar around.
My test html is given below. With the iframe hidden the mouse coords are obtainable. With the iframe visible things get buggy.
Where the "background_foriframe.html" is just a html file with a background layer using a "DIV" tag. Code:
I run a streaming site and am looking to have the option on a chat room next to the stream. Not everyone likes having the chat facility so I'd like to make it optional.
As the page loads I'd like the content to look like the diagram below with the stream (iframe1) taking up 95% of the page and the other 5% being taken up by an image which will say "open chat". The chat (iframe2) would have a width of 0%. [URL]
Then when the "open chat" image is clicked I'd like the chat (iframe2) to become 35% and the stream (iframe1) to become 60%. If someone could make a nice sliding effect when the image is clicked that'd be even better. Here's a diagram to show what it'd look like with the resized iframes. [URL]
Is it possible to add an onclick event to an iframe or perhaps a DIV that holds an iframe?
In specific I am using the Facebook Open Graph like button code...
What I would like to do is add a simple onclick event to it so that I can run a process when the user clicks on it, at the moment I am just trying alert but cannot get it to work. By setting the iframe within a DIV with height/width specs set would an onclick event work within the DIV?
I apologise if this is in the wrong section. I have built a website using iframes at: [URL] but when clicking through the menu, the address bar still stays at [URL] no matter which page is loaded into the iframe. I have seen a number of javascripts around that can change this, but most do not seem to work anymore. Has anyone a sure way to correct this please :)