Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
183
rated 0 times [  184] [ 1]  / answers: 1 / hits: 26207  / 13 Years ago, sat, april 16, 2011, 12:00:00

I have a list of links that open in an iframe, like:



<ul id=frameTrigger>
<li><a target=iframe1 href=aaa.html><img src=aaa.jpg></a></li>
<li><a target=iframe1 href=bbb.html><img src=bbb.jpg></a></li>
<li><a target=iframe1 href=ccc.html><img src=ccc.jpg></a></li>
</ul>


I need to update another div after the link is clicked. Specifically, I need to call a function that checks the frame's src attribute and update the div. If I do a:



$(#frameTrigger a).click(function() {
var iframe = $(iframe[name=iframe1]).get(0);
console.log(iframe.contentWindow.location.href);
// the problem here is that that the iframe.window.location will
// change AFTER this function returns
});


I do not get what is expected.


More From » jquery

 Answers
70

I'm guessing you get the old value instead of the new one? You may want to wrap your function in a setTimeout of 1ms to allow the update to go through.


[#92692] Thursday, April 14, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cayden

Total Points: 314
Total Questions: 107
Total Answers: 101

Location: Slovenia
Member since Wed, Apr 6, 2022
2 Years ago
;