Forum Moderators: open

Message Too Old, No Replies

pull a javascript variable to other page

both pages... in the same domain

         

sugar2

12:59 am on May 21, 2005 (gmt 0)

10+ Year Member



hi
i have 2 pages, one have two javascript variables assigned, lets say...

PAGE 1:
<script>navnext = 1</script>
<script>navlen = 7</script>

PAGE2:
how can i pull the PAGE1 variable values?

i saw a old post in this forum, but it is about pulling variables from a child frame to a parent frame... that didnt work for two different pages...

note1: also my two pages are in the same domain.

note2: i know that the PASSING method using SUBMIT button works well in this cases, but the thing is that i wont pass the variable... i want to pull the variable...
only using javascript or DOM, no dinamic php either asp...

i tried to changing the context of the page like

<base href='http://mypage.domain/' target='_self'>
with no results, also i need to call the same pair of variable of too many pages from the same page...

any javascrip or DOM idea?

thannks members

orion_rus

7:06 am on May 21, 2005 (gmt 0)

10+ Year Member



You can open second page from the first page with window.open, then you can have access to first page variables like this:
document.write (window.opener.document.forms[0].target.value);
or document.write(window.opener.navlist);
good luck to you

sugar2

4:52 pm on May 21, 2005 (gmt 0)

10+ Year Member



thanks for the fast response orion_rus, but i think i cant open like 30 windows before load my current page.. because i need to read like 30 pairs of varaibles from like 30 different pages...

to be honest i will consider recaltulate the variable values from the calling page instead of trying to call remote values...

thanks

sugar2

6:24 pm on May 21, 2005 (gmt 0)

10+ Year Member



ok, this is the panorama: i have a yah_oo-store, and i cannot use dynamic scripts inside orpduct pages, this time im doing a "Special Items page By Department", and it its a simple page with links to each page wich have special items, things become hard since, each page wich have special items have a link like : www.mypage.mydomain/department_page.html?pageNum=5, because i have a javascript dynamic pagination wich load only the items marked as "special" in the current department page
actually i have like options:

1- load the pages by iframes and then get the variable values (slown loading time)
2- create a template wich recalculate the variable values and pull it by a .js include, (daily upload)
3- recalculate the variable values inside the pulling page (hard to coding), no daily updates, once published is fast loading

thanks for the advising

Rambo Tribble

2:45 pm on May 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Variable persistence is the sole intention of cookies. That principle has been subverted by ad trackers, but it remains the only real provision for passing values between pages.

The window.name property is sometimes used to get around this limitation and can be effective if the variable(s) need not persist outside a single session.

Rambo Tribble

3:00 pm on May 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Another approach is to append name/value pairs to the URL as GET data. The number of variables you mention, however, may well present some challenges in management with this approach.

sugar2

4:45 pm on May 23, 2005 (gmt 0)

10+ Year Member



thank but, since its imposible to load like 30 new windows, only to load a page wich pull their 60 variables..

i think the solution is:

1- Put a simple link in the calling page, and in the link page put a javascript wich look if its page is called from certain page and then if yes, redirect to the proper URL, and if not, let it load.
i mean like that:
PSEUDOCODE:

<SCRIPT> 

NO WORKING

if (document.referrer = "http://store.crafta.com/specials-by-department.html")
location.href = "?pageNum=5";

</SCRIPT>


or 2- Calculate the variables values inside the calling page. (i think this is the better and harder solution...

thanks everybody

Rambo Tribble

10:30 pm on May 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The window.name property is a property of the current window that will persist when the next page is loaded. No one is suggesting you create and load 30 windows. Just one.

sugar2

10:54 pm on May 23, 2005 (gmt 0)

10+ Year Member



its possible that maybe you havent read the first 2 or 3 responses of this topic, the thing is to pull variables from 30 other pages, and the idea is without loading or hitting that pages first.
thanks