javascript
  • jquery
  • location
  • 2012-10-25 40 views 0 likes 
    0

    亲爱stackoverflowers,似乎无法添加JS变量parent.href.location

    我会LIK一个变量添加到以下JS行:

    setTimeout("parent.location.href = 'http://www.url.com/lists.php?listid=';",2000); 
    

    我该怎么办呢?我似乎无法得到'正确的。

    setTimeout("parent.location.href = 'http://www.url.com/lists.php?listid=' + variable;",2000); 
    

    回答

    5

    将函数处理程序传递给setTimeout()总是比较好。此外,它很容易与放置引号解决您的问题:

    setTimeout(function() { 
        parent.location.href = "http://www.url.com/lists.php?listid=" + variable; 
    }, 2000); 
    
    +0

    @ alex23为了什么? – VisioN

    0

    使用功能重定向如下....

    function Redirect(val) 
    { 
        parent.location.href = 'http://www.url.com/lists.php?listid='+val; 
    } 
    
    setTimeout(" Redirect('"+variable+"')",2000); 
    
    相关问题