user850234
user850234

Reputation: 3463

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

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.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.

Upvotes: 0

Views: 196

Answers (2)

JJJ
JJJ

Reputation: 33153

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" );
}

Upvotes: 0

solendil
solendil

Reputation: 8458

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

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

Upvotes: 4

Related Questions