Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2013
    Thanked 0 Times in 0 Posts

    Unhappy Problem with window.location

    Hello everyone,

    For an application at work, I'm creating a page that redirects to another page and passes variables as Querystrings.

    The problem is, once I create my link and open it, I do not get the desired result.
    In this example :

    document.write(test); ---> gives me the url
    window.location.href = test; ---> completely changes the link given in document.write(test) ---> KWInst doesn't return 30 but gives something like <span name="_P_SUM3" .... />

    So I guess my question is, how to I open a window where the URL = the result of "document.write(test)" ? I can't directly pass the variables in javascript or else the variables just return a <span> in the link...

    Any ideas ?

    Thanks a lot


    <script type="text/javascript">
        var KWInst = sysvar("_P_SUM3");
        var KWhCumul = sysvar("_wh_V[4]");
        var link = "";
        var linktwo = "&KWhCumul=";
        var test = link + KWInst + linktwo + KWhCumul;
        window.location.href = test;

  2. #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Thanked 4,945 Times in 4,906 Posts
    Ummm...for starters, stop using document.write. Not only is it very obsolete, but it has the horrible property that, if you use it after a page is fully loaded, it WIPES OUT all current content on the page, including the JavaScript used to do the the document.write.

    But anyway...I suspect that you are fooling youself.

    Let's suppose that sysvar("_P_SUM3") actually contains <span name="_P_SUM3" class="zamboni">30</span>

    If you then document.write that to the screen, what do you think you will see?

    HINT: You will *NOT* see <span name="_P_SUM3" class="zamboni">30</span>

    Instead, you will see simply 30

    The HTML tags DISAPPEAR!

    If you want to see what it *REALLY* contains, you could do
    document.write( sysvar("_P_SUM3").replace("<","&lt;");
    or maybe
    document.write( "<pre>" + sysvar("_P_SUM3") + "</pre>" );
    So no suprise that when you dump that into the HREF you get what you think is garbage but what is actually the correct contents of the whatever-the-heck-sysvars is.
    Be yourself. No one else is as qualified.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts