Reputation: 26835
This used to work, but for some reason it doesn't anymore. I use a javascript to change the source of an iframe and then refresh it. The reason is I want to send a variable into the iframe before it is viewed.
I added som debug code, and it shows "debug 1" but not "debug 2".
What might be the issue?
$("#upload_iframe").attr("src", "/editor/upload/?dir=" + dir);
// ---------------------------------
// THESE LINES DON'T WORK - STOPS AFTER FIRST DEBUG IS RUN...
// ---------------------------------
alert('debug 1');
$("#upload_iframe").contentWindow.location.reload(true);
alert('debug 2');
// ---------------------------------
$("#upload_file").dialog('open');
Upvotes: 0
Views: 677
Reputation: 38150
As you want to access the dom and not the jquery object you should add [0] :
$("#upload_iframe") //is an array of matching dom objects
$("#upload_iframe")[0] //is the first matching dom object
You might also add a random string to prevent browser caching:
$("#upload_iframe")[0].contentWindow.location.href = "/editor/upload/?dir=" + dir + "&rid=" + Math.random();
Upvotes: 4
Reputation: 3708
Personally, I've not had much luck using the "reload()" method. Try this:
$("#upload_iframe").contentWindow.location.href = $("#upload_iframe").contentWindow.location.href;
Upvotes: 2