Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript重定向:symfony路由中的脚本不工作_Javascript_Symfony_Routes_Twig - Fatal编程技术网

Javascript重定向:symfony路由中的脚本不工作

Javascript重定向:symfony路由中的脚本不工作,javascript,symfony,routes,twig,Javascript,Symfony,Routes,Twig,我从中重定向的页面I: <a class="uk-overlay" href="{{ path("shot.view",{"id" : id}) }}"> <img class="uk-border-rounded" src="{{ largeSquare(shot) }}"> <div class="uk-overlay-area uk-border-rounded"> <div class="uk-align-rig

我从中重定向的页面I:

<a class="uk-overlay" href="{{ path("shot.view",{"id" : id})  }}">
    <img class="uk-border-rounded" src="{{ largeSquare(shot) }}">
    <div class="uk-overlay-area uk-border-rounded">
        <div class="uk-align-right uk-margin-small-top">

            {% if is_granted('ROLE_USER') %}

                {% if app.user.isOwnStar( id ) %}
                    <button class="uk-icon-button uk-icon-star uk-margin-small-right" style="background: #00a8e6;"></button>
                {% else %}
                    <button class="uk-icon-button uk-icon-star uk-margin-small-right" onclick="window.location='{{ path("shot.giveStar",{"id" : id})  }}'"></button>
                {% endif %}

                {% if app.user.isOwnFavorite( id ) %}
                    <button class="uk-icon-button uk-icon-heart uk-margin-small-right" style="background: #d32c46;"></button>
                {% else %}
                    <button class="uk-icon-button uk-icon-heart uk-margin-small-right" onclick="window.location='{{ path("favorite.add",{"id" : id}) }}'"></button>
                {% endif %}

            {% endif %}
        </div>
    </div>
</a>  
e、 路径的g路径(“shot.giveStar”,“id”:id})

前三行被忽略,只执行重定向命令

在重定向之前执行代码,我必须更改什么

window.location.href = '' 
// or
window.location.replace("")

虽然您的代码可能(或不)工作,但如果您添加一个关于问题的简要说明以及您的代码是如何解决问题的,那就太好了。照原样,它不能提供一个完整的答案,根据代码的工作原理是肯定的。如果我用
替换
标记,并将覆盖从
更改为
,一切都正常。我使用了:
javascript:document.window.location.href
-同样的问题它不是document.window,而是window.document:您还可以尝试一下onclick=“function(){window.location.href='xyz';}
window.location.href = '' 
// or
window.location.replace("")