开发者

If URL not equal to specified URL then apply this jQuery? [closed]

开发者 https://www.devze.com 2023-04-10 07:58 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

if the current uURL is not same as specified then apply jQuery. BUT THIS WONT WORK

<script type="text/javascript">
var myurl = http://example.com/document.html;
var currenturl = window.location
if(myurl 开发者_如何学运维== currenturl) {
    $("<span>url's match</span>").replaceAll("body"); // check replaceWith() examples
}
</script>

Also current URL can be a standard link http://example.com/ or as shown in example.


You need to quote your URL:

var myurl = http://site.com/document.html;

// Should be
var myurl = "http://site.com/document.html";

For best practice, don't omit the ; here:

var currenturl = window.location
//---------------------------^^^^


You are missing quotes on the first line:

var myurl = "http://site.com/document.html";

And it should be != on the third line

0

精彩评论

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

关注公众号