jquery - javascript function not taking arguments -


this question more complex realize.

when page loads, checks cookie (usercookie). if exists, calls function in external .js file. function situated in jquery file , 3 things. hides come stuff, sets variable (userloggedin) true, , displays welcome message users. however, acting strange. in order function work, have define "new" before object. if don't that, won't work @ all. if use it, refuses take arguments. take look.

keep in mind situated in $(document).ready(function() {}

userlogged = new function($name)   {     userloggedin = true;     $('.socialicons').hide();     $('#signup').hide();     $('#login').hide();      document.getelementbyid('cookieelement').innerhtml = "welcome back, " + $name + "!"; } 

here how call function main document.

<script type="text/javascript" id="cookiescript"> //checks usercookie , gets value var query = true; if (query === true)  {  cookievalue =  "seth"; userlogged(cookievalue); }  </script> 

some of code returned php query mysql, know code works fine.

so question is, how create universal function in js file can call anytime user logs in somehow (eg. cookie detected, form entry)?

you have declare parameter @ declaration part function functionname(parameter)


Comments

Popular posts from this blog

javascript - JS causing window size to be bigger than necessary - Dropdown bug -

How to mention the localhost in android -

php - Calling a template part from a post -