I have an iframe on the page and I am trying to call a function on the parent page form the iframe. I noticed that when i use:
window.top
that works fine in Chrome. However, when i use:
window.parent
that works for IE.
How can i write a method that checks both and uses the correct method? Also i am using jquery and was trying to find a way use that to do this. Any help is appreciated.
So i doing something wrong for some reason but parent.function() works fine in all browser. Sorry for confusion
Related
I have a problem that is specific to IE9.
We are using Autodesk MapGuide which has a framework of several nested Framesets. I am trying to call a Javascript function that sits within an IFrame that is within the top level frameset. (Please I dont want to discuss the merits or otherwise of framestes here.)
I have adapted some code I found in another thread using Jquery
window.top.$("#MyIframe")[0].contentWindow.MyFunction();
This works perfectly in IE7 and IE8, but as soon as I try it in IE9 I get the following error:
TypeError: Unable to get value of the property 'contentWindow': object
is null or undefined
I suspect that it is struggling with the framesets and can't find '#MyIframe'.
Is there some other format I can try to get around this? Many thanks in advance for your help.
I might be tired but I just can't figure out what the problem is. What I'm trying to do is open a link in a popup window. I got this code below working before but I removed it.
About
However, it stopped working now when I put it back. I even got it working on jsFiddle so I'm at lost on what to do. I'm assuming something must be blocking it from running?
The code is short and simple so I figured someone here might have an idea what could cause this.
EDIT: Sorry I should have thought of it. I guess I should sleep. Anyway here's a demo-website where I reproduced the problem http://testmycode.tumblr.com/ The problem is the "About" link, pressing it returns nothing.
OK, it seems like somewhere in your code you have changed the window variable to a custom function. When you try to call window.open (more specifically, document.window.open), the method open simply doesn't exist in the function window, which causes it to throw an error.
Check this out:
You somewhere changed it to a function by doing document.window = ....
It's MooTools 1.2.4 which changed it:
To fix it, simply using an EventListener and problem solved! (Inline codes are bad practice anyway.)
<a class="about">About</a>
$(".about")attr("href", "#").click(function(e){
window.open(...);
e.preventDefault();
});
The snippet you shared works when I append it to the page we are at, in Google Chrome. Which makes me wonder which browser you are having the trouble in. So I would encourage you to try the snippet you shared in Google Chrome, and if it works there then you will know it is a browser specific kind of bug, in which case I would try adding a semicolon after return false.
I am wondering if I can have the unload method in Javascript do a button.click; or a document.getElementById('target').click();
The reason for this is I want to clear the information in the browser but I can't seem to get the unload method to work right. But I don't even know if the unload method is capable of doing a button.click or a document.getElementById('target').click(); Is there like a list of things this method can or cannot do? here is the code I am trying to get working.
window.onunload=leave;
function leave() {
//alert("Leaving");
document.getElementById('kioskform:broswerCloseSubmit').click();
}
The alert seems to be showing in everything ("IE, FireFox,Safari") but in Chrome ('don't know why) but i can't seem to get the clear options i am using to work with the unload method. Not to mention I am wondering if there is a good way to detect which browser the individual is using to load in different parts of the unload script any idea's or suggestions or advice is greatly appreciated.
If you were to use jQuery , you could use the DirtyForm plugin. This would accomplish what you are trying to do.
I have a function in an iFrame (same domain) that I want to call from a popup.
So basically I want to do something like window.opener.document.getElementById('topFrame').contentWindow.setActive('1');
In the window.opener of the popup, i have an iframe with the id "topFrame" (and name "topFrame" in case that's a better solution) in which the function setActive('1') must be executed.
However the code stated above does not work and google isn't really helping in finding solutions for this specific case.
Anyone has an idea?
Thx
Your line should actually work and the problem probably a timing issue: most likely your iframe hasn't finished loading at the time you are trying to call its function. Placing your call after load or DomReady should do the trick.
(You can also experiment by wrapping your call in a timeout and see if it works at a later point).
if you are opening the pop up from the iframe window then you should use
window.opener.setActive('1');
because window.opener will itself return you the iframe window .it might be the case because i was also committing this mistake. hope your problem is solved :)
I'm using the hidden iframe method for file upload and it does not work properly in IE. The problem is that the function to be called after the server response is not called in IE.
The line is
document.getElementById("iframe_id").onload = uploadDone;
I also tried window.iframe_id.onload, document.iframe_id.onload, etc
I don't think that there is any other error in code as this works fine in FF and Chrome.
I tried an alert instead of the function name (uploadDone) and it works (though shows an error in the script debugger). But replacing the complete function, like:
...onload = function () {...};
there works neither.
Can somebody help me make this work in IE?
Thanks in advance.
I would highly recommend you look into using JQuery or another javascript framework. It will save you a lot of pain....
You can
window.onload = Startup
in the frame document and from there call whatever function you want in the parent document.
I can look for some code if you want...