开发者

Why the page continuously reloads after using window.location in the script

开发者 https://www.devze.com 2023-04-12 20:25 出处:网络
I am using cakephp and trying to define this in the script of ctp file. The output is also coming right with it.

I am using cakephp and trying to define this in the script of ctp file. The output is also coming right with it.

if(window.location开发者_如何学C.pathname="/users/register"){
    $('body').css('position', 'relative');
    $('#footer').css('bottom', '0px');
    $('#footer').css('position', 'absolute');
}

But the problem is the page keeps on constant reloading automatically when the defined pathname is visited. Is there any way to stop reloading continuously. The usage of this is requierd for proper output.


use == (comparison) instead of = (assignment) :)

if(window.location.pathname=="/users/register"){


You're using = instead of ==.

In any case you should use CakePHP's functions to check for the controller/view combination instead of what you're doing now:

if( $this->params['controller'] == 'users' && $this->params['action'] == 'register' ) {
    echo $this->Html->scriptBlock( "$('body).css('position', 'relative'); etc etc" );
}
0

精彩评论

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

关注公众号