Naveed_Manzoor
asked on
Pass JS variable in query string
I have few divs and images on a page. Clicking on any image shows the respective div and hide other. This is being done through js function. By default div one is open. Now if my visitor is on div 3 , I would like to have an image clicking on that image should refresh the page with div 3 open. I also want to auto refresh page after 3 minutes opening same div on which user is.
I am using PHP and javascript.
I am using PHP and javascript.
function togLayer(id)
{
if(currLayerId) setDisplay(currLayerId, "none");
if(id) setDisplay(id, "block");
imgid = 'img' + id;
var imgelm = document.getElementById(imgid);
var previmg = document.getElementById(previmgid);
if (previmgid == imgid)
{
imgelm.src='images/open_' + id + 'over.jpg';
imgbool=id;
}
else
{
imgelm.src='images/open_' + id + 'over.jpg';
subid = previmgid.substring(3,15);
previmg.src='images/open_' + subid + '.jpg';
imgbool=id;
}
currLayerId = id;
previmgid = imgid;
}
ASKER
Can I not pass js var in query string ?
you can but that will attract lot of changes to the code and everytime, you will have to preserve that variable..
ASKER
can you provide me cookie setter and reader code ?
Use the hash
location.hash="#div3"
location.hash="#div3"
ASKER
mplungjan
can you please provide me details of using hash
can you please provide me details of using hash
ASKER
i have hash for all my links. Now I need a button that refresh the same page with hash of the page. That's what am trying to do .
<A HREF="openqportal.php getLocationHash()"><img src="images/iconRefresh.jp g" alt="" name="Refresh" width="28" height="38" border="0" id="Refresh" /></a>
how can I concatenate hash value with page name ???
I want to makew this link .... penqportal.php#bus
<A HREF="openqportal.php getLocationHash()"><img src="images/iconRefresh.jp
how can I concatenate hash value with page name ???
I want to makew this link .... penqportal.php#bus
You mean
<A HREF="openqportal.php" onClick="location.hash='#b us'; return false"><img src="images/iconRefresh.jp g" alt="" name="Refresh" width="28" height="38" border="0" id="Refresh" /></a>
or just
<A HREF="#bus"><img src="images/iconRefresh.jp g" alt="" name="Refresh" width="28" height="38" border="0" id="Refresh" /></a>
if you are already in the page or
<A HREF="openqportal.php#bus" ><img src="images/iconRefresh.jp g" alt="" name="Refresh" width="28" height="38" border="0" id="Refresh" /></a>
if you are in another page
<A HREF="openqportal.php" onClick="location.hash='#b
or just
<A HREF="#bus"><img src="images/iconRefresh.jp
if you are already in the page or
<A HREF="openqportal.php#bus"
if you are in another page
If you need to actually LOAD the page again, then that is something else
ASKER
I am on same page but need to reload the page with hash value like
<A HREF="openqportal.php#bus" >
<A HREF="openqportal.php#med" >
This med and bus I have to get from url. Function for getting hash is getLocationHash() (I am using). Now I have to form a url like pagename + hash value <A HREF="openqportal.php#med" >.
<A HREF="openqportal.php#bus"
<A HREF="openqportal.php#med"
This med and bus I have to get from url. Function for getting hash is getLocationHash() (I am using). Now I have to form a url like pagename + hash value <A HREF="openqportal.php#med"
so
<A HREF="openqportal.php" onClick="location.replace( this.href+ getLocatio nHash()); return false"><img src="images/iconRefresh.jp g" alt="" name="Refresh" width="28" height="38" border="0" id="Refresh" /></a>
<A HREF="openqportal.php" onClick="location.replace(
ASKER
This is not working. Its doing nothing. I need te reload the page too
That is sort of defeating the point of using HASH, then just use query string
But if you need, try this
<A HREF="openqportal.php" onClick="location.hash=get LocationHa sh(); location.reload(1); return false"><img src="images/iconRefresh.jp g" alt="" name="Refresh" width="28" height="38" border="0" id="Refresh" /></a>
But if you need, try this
<A HREF="openqportal.php" onClick="location.hash=get
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
So close it
save current open div id in cookies and keep on updating this cookie everytime user switched slide.. On refresh, check for this cookie value and show current slide..
note: keep cookie expiry at the end of session..