Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change DIV Width with Cookie Set

Status
Not open for further replies.

Sams04

Programmer
Sep 10, 2013
1
Its working but when i browse the site its change to fixed.

Code:
 <html>
<head>
<script type='text/javascript' src="[URL unfurl="true"]https://code.jquery.com/jquery-latest.min.js"></script>[/URL]
<script type='text/javascript'>
function ChangeWidth(width , state)
{           
        $('container').setStyle({ width: width, minWidth: width });
        $$('.width').invoke('setStyle', { width: width, minWidth: width });        
        tem.global.showInlineNotification( 'Width changed to ' + state,{ 'displayForSeconds': 5 } );        
        tem.Cookie.set( 'width_state', state );
        
}

document.observe("dom:loaded", function(){
   
   $("change_width").observe('click', function() {   
    if(ipb.Cookie.get( 'width_state' ) == 'fluid')
    {
         ChangeWidth('1000px','fixed');
    }
    else {
         ChangeWidth('90%','fluid');
    }
    
  });
    
});
</script>
</head>

<body>
<div class = "width">
<div id="container" class="clearfix"> 

<a href="#" id="change_width"><img src="width.jpg" alt="Change Width"></a>

</head>
</html>
 
Code:
 [highlight #F57900]$$[/highlight]('.width').invoke('setStyle', { width: width, minWidth: width });

Is that a typo?

also what does this show?
Code:
alert(ipb.Cookie.get( 'width_state' ))

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Free Dance Music Downloads
 
@1DMF
i'd guess it is a shortcut for the prototype.js or underscore.js framework that also has an invoke() method. but am just guessing.

in any event, it does not seem to be being loaded by the excerpt provided.

and since jquery is (we know) loaded, there will be errors thrown by the use of $(selector).observe() as observe is not a method in jQuery.

the whole code block seems a mess and the problem enunciated by the OP is far from clear. Difficult to know what to suggest to the OP other than

1. articulate the desired aim with clarity. Do not assume that we have any knowledge that you have.
2. explain what steps have been taken to achieve the aim, and against each code used what errors and other experiences are presented and what you have done to debug them.

[i.e. business as usual ]
 
I did wonder about the observe method, but as I don't know the entire JQuery protocol, I assumed it was a method I wasn't familiar with.

the same with

document.observe("dom:loaded" ...

I know it as

$(document).ready(function(){...

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Free Dance Music Downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top