/    Sign up×
Community /Pin to ProfileBookmark

Passing info from one page to the other without location.search

Hi All.

I need to pass some variables from one page to another, using javascript. Basically, I have a main page, and a search page. On the main page, the user selects various search criteria, clicks search, and goes to the search page, which displays results, with selected criteria available for further changes.

Due to reasons I’d rather not go into, the search page itself uses an iframe, and search results are displayed by a server-side script in that iframe. So, this means I actually have to pass query parameters into an iframe on a subsequent page. Currently, I’m doing this through the location.search property, but because search page’s iframe defaults to a blank screen, as you change criteria and search again (without leaving the search page), it kinda “blinks”, which is annoying. I can have the search page open search results using a “target” attribute, but then my location URL won’t match the result set – since it doesn’t look like a default unchanging URL (it has a bunch of parameters appended from the front page), users will be tempted to copy/paste it, and the experience will be quite confusing and frustrating.

I hope that’s somewhat understandable. The questions that I have, based on above, are:

  • Is there any way to pass variables from one page into the other, through javascript, without using location.search or a server-side script?

  • Can I modify location.href or location.search without actually causing the browser to reload the page? I can keep these in-sync with the page, but modifying these causes a reload and all of my state is gone.
  • I’ve considered having one page and hiding/showing layers, but would like to explore all other possibilities before trying that out.

    to post a comment
    JavaScript

    2 Comments(s)

    Copy linkTweet thisAlerts:
    @FangAug 17.2005 — [I]cookies[/I] or as you are using [I]iframes[/I], the data can be read from the main document or another [I]iframe[/I]
    Copy linkTweet thisAlerts:
    @JoeyGAug 17.2005 — Check out the XHTTPRequest object on Google. It's pretty complicated, but it will allow you to communicate with the server without refreshing the page.

    This will both:

    1) Allow you to eliminate the iFrame (unless you need it for other reasons)

    2) Get rid of your annoying "blink" which is caused by page refresh delays.

    3) If you really get into it, you could code a search-as-you-type engine such as [url=http://www.google.com/webhp?complete=1&hl=en]Google Suggest[/url]

    Happy coding!
    ×

    Success!

    Help @voidhawk spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.25,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...