Jump to content

Recommended Posts

Hello, all. I am trying to figure out some things for my personal site, and I've run into a hopefully small block. I have the following HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>v8:ColdSteel</title><link rel="stylesheet" href="css/style.css" /><meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /><script language="Javascript" type="text/javascript" src="page2.js"></script><style id="cssStyle"></style></head><body><div class="pic_select_images_inner">	<ul>		<li><img src="images/thumb_terp_wood.gif" height="72px" width="72px" /></li>		<li><img src="images/thumb_docos_poster.gif" height="72px" width="72px" /></li>		<li><img src="images/thumb_aol_site.gif" height="72px" width="72px" /></li>		<li><img src="images/thumb_rip_samurai.gif" height="72px" width="72px" /></li>		<li><img src="images/thumb_paint_hand.gif" height="72px" width="72px" /></li>		<li><img src="images/thumb_ae.gif" height="72px" width="72px" /></li>	</ul></div>	<div class="page_select">	< <span>1 </span><a href="" id="page2">2 </a><a href="#">3 </a><a href="#">4 </a><a href="#">5 </a> <a href="#">></a></div></body></html>

and my page2.js looks like:

window.onload = initAll;function initAll() {	document.getElementById("page2").onclick = initPageTwo;}function initPageTwo() {	document.getElementById("cssStyle").innerHTML = ".pic_select_images_inner ul {margin-left:-173px;)";}

My question is how do I keep the page from reloading back to its original state when I click on the link (id="page2")? In otherwords, how do I keep the changes made by page2.js?

Link to post
Share on other sites

I'm really not sure what you're up to here. I don't think you've provided enough information. Here's what I'm getting out of this: a user on page 1 clicks a link for page two. this creates a style change. when page 2 loads, you want the style change to remain.If that's it, I don't understand why page 2 doesn't already know what style features it's supposed to have. Unless maybe page 2 is supposed to look different depending on the page the user is coming from?Maybe I've misunderstood. But it probably doesn't matter, because there is almost certainly a better way to do what you're doing.The thing is, you cannot change Document A and expect the change to be reflected in Document B. The documents are independent of each other. What you can do is save some information somewhere, like (1) on your server (through a server-side script) or (2) in a cookie (which gets stored on your user's browser). Many authors store information in cookies that they read when the page loads. The information can be used to alter styles to a user's preference, for example. Is that close to what you're doing?

Link to post
Share on other sites
  • 2 weeks later...

Yes, your assumptions were right. I'm sure there was a much better way to do what i did, also, but I am very new to JS, and am trying to figure stuff out. If i recall correctly, in the initPageTwo function, I simply needed "return true;" before the closing curly bracket.I changed the whole thing around, anyhow, and get everything works as I need to. Thank you for trying to help, though :)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...