external.menuArguments.location.href带参数&时获取的网址,提示错误为空或不是对象。
但是external.menuArguments.document.title就能正确,应该就是网址里带有&参数的原因。求正解,或解决方法。我用的是获取当前地址,然后跳出保存页面,代码如下:
<script LANGUAGE="JavaScript">
if (external.menuArguments){
var parentwin = external.menuArguments;
if (parentwin.document.selection) {
var sel = parentwin.document.selection.createRange().text;
}
if (!sel) {
var sel = '';
}
var url = parentwin.location.href;
var title = parentwin.document.title;
if (parentwin.event.srcElement.tagName == "A") {
url = parentwin.event.srcElement.getAttribute("HREF");
title = parentwin.event.srcElement.innerText;
}
void(window.open('addurl.asp#t='+escape(title)+'&u='+escape(url),'_blank','scrollbars=no,width=480,height=200,left=275,top=150,status=no,resizable=yes'))
} else {
history.go(-1);
}
</script>

解决方案 »

  1.   

    这个是在右键里弹出访问页面,然后
    var url = parentwin.location.href;
    这一行就会提示出错,前提是当前网址带—参数,,不知道有没有什么解决方法
      

  2.   

    var url = parentwin.location.href;这里出错的?
    parentwin.location呢
    另外你带参数时是不是拼错URL了
      

  3.   

    谢谢你的回答,
    刚才我试了一下,
    parentwin.location的值为undefinedURL应该没错的,直接在百度随便搜索,然后点第二页的页面就不行了,如
    http://www.baidu.com/s?wd=baidu&pn=10&usm=1
    这里带了&号,就会出错,,很奇怪
      

  4.   

    奇怪的是,
    external.menuArguments.location.href获取地址出错,
    但是
    external.menuArguments.document.title就能正确获得标题
      

  5.   

    试试
    external.menuArguments.document.location呢
      

  6.   

    external.menuArguments.document.location  external.menuArguments.document.location.href
    external.menuArguments.document.href
    全部提示拒绝访问external.menuArguments.location.href
    地址无参数时,正常。有参数时提示为空或不是对象
      

  7.   

    晕,我刚才试了这个网址
    http://topic.csdn.net/u/20110108/00/2c05bad1-0271-4bda-9bf7-e13075708ad8.html?seed=1934861700&r=71096018#r_71096018也是带有&号的,用
    external.menuArguments.location.href
    时成功,那就是百度的地址有问题?
    http://www.baidu.com/s?wd=baidu&pn=10&usm=1这个地址就会提示为空或不是对象 
      

  8.   


    external.menuArguments.location.href 
    改成
    external.document.menuArguments.location.href
    试试
      

  9.   

    添错位置了,是这样把
    external.menuArguments.location.href  
    改成
    external.menuArguments.document.location.href
    试试