0

再会。

我想检查当前浏览器窗口路径名是否具有特定值...

但我的代码不起作用......有什么帮助吗?

               jQuery(function($){
                    var pathname = window.location.pathname;

                    if ($pathname == 'http://google.com') {
                        alert($pathname);
                    }
                });

谢谢你

4

1 回答 1

5
if ($pathname == 'http://google.com') {

应该

if (pathname == 'http://google.com') { //no $

因为您将其声明为

var pathname = window.location.pathname;
于 2013-03-18T12:24:55.027 回答