admin管理员组文章数量:1323714
I have the below code :
$(document).ready(function() {
$(".rightImage").last().append("<iframe src=' education.co.uk/EmailSignup/website_email_sign_up.html' width='180px'frameborder='0' height='250px'></iframe>");
});
The above code adds an iframe to a class, the problem is it appears on every page. Is there a way to filter out the above function to work on every page except my homepage? I don't have control of the parent's html so that's why I have to do it this way.
Thanks
I have the below code :
$(document).ready(function() {
$(".rightImage").last().append("<iframe src='http://images.findel- education.co.uk/EmailSignup/website_email_sign_up.html' width='180px'frameborder='0' height='250px'></iframe>");
});
The above code adds an iframe to a class, the problem is it appears on every page. Is there a way to filter out the above function to work on every page except my homepage? I don't have control of the parent's html so that's why I have to do it this way.
Thanks
Share Improve this question edited Mar 14, 2014 at 11:26 Zaheer Ahmed 28.6k12 gold badges76 silver badges112 bronze badges asked Mar 14, 2014 at 11:25 user3120015user3120015 1814 gold badges6 silver badges18 bronze badges6 Answers
Reset to default 2Well, try this:
$(document).ready(function() {
if (document.location.href != 'homepage_url') {
$(".rightImage").last().append("<iframe src='http://images.findel- education.co.uk/EmailSignup/website_email_sign_up.html' width='180px'frameborder='0' height='250px'></iframe>");
}
});
You can use window.location
try:
$(document).ready(function() {
if(window.location !== "homepageurl"){
$(".rightImage").last().append("<iframe src='http://images.findel-education.co.uk/EmailSignup/website_email_sign_up.html' width='180px'frameborder='0' height='250px'></iframe>");
}
});
check the window.location
and execute the steps in the document.ready if its not a match
$(document).ready(function () {
if (window.location != "exceptionURL") {
$(".rightImage").last().append("<iframe src='http://images.findel- education.co.uk/EmailSignup/website_email_sign_up.html' width='180px'frameborder='0' height='250px'></iframe>");
}
});
add a filter with the url
$(document).ready(function() {
if(window.location.href!='http://yourhomepage'){
$(".rightImage").last().append("<iframe src='http://images.findel- education.co.uk/EmailSignup/website_email_sign_up.html' width='180px'frameborder='0' height='250px'></iframe>");
}
});
You can check the url:
$(document).ready(function() {
if(window.location.href.indexOf('http://www.example.') != 0) {
$(".rightImage").last().append("<iframe src='http://images.findel- education.co.uk/EmailSignup/website_email_sign_up.html' width='180px'frameborder='0' height='250px'></iframe>");
}
});
If the current url starts with 'http://www.example.' it wont execute the following code, else it will append the code.
You can try this:
$(function(){
if(!location.pathName.contains('home')){
$(".rightImage").last().append("<iframe .... height='250px'></iframe>");
}
});
check if related a specific word about your home page is available in the url.
本文标签: javascriptjQuery excluding documentready event for a specific pageStack Overflow
版权声明:本文标题:javascript - jQuery excluding document.ready event for a specific page - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742127176a2421993.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论