开发者

How can I check whether a button (wpv_1266351) in a frame does or does not exist using Jquery or Javascript?

开发者 https://www.devze.com 2023-02-19 12:05 出处:网络
iframe Info:id=\"AssessmentsIFrame\" button Info: id=\"wpv_1266351\"开发者_StackOverflow$(\'#AssessmentsIFrame\').contents().find(\'#wpv_1266351\');

iframe Info: id="AssessmentsIFrame"

button Info: id="wpv_1266351"开发者_StackOverflow


$('#AssessmentsIFrame').contents().find('#wpv_1266351');


First, the iframe HAS to be on the same domain name, otherwise you can't get to anything in it.

var ifr = $('#'),
 ifrDoc = ifr.contentDocument || (ifr.contentWindow && ifr.contentWindow.document) || ifr.document,
 button = ifrDoc.getElementById('wpv_1266351');

button will either be null or a reference to your button. It's not really any simpler using jQUery since jQuery doesn't know how to get the iframe document reference by itself.

0

精彩评论

暂无评论...
验证码 换一张
取 消