SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Apr 2002
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    javascript is losing special characters

    hi there,

    i have some javascript pasted as the destination in one of my buttons on my link toolbar in IE. The code is:

    javascript:
    tt=window.document.title;
    loc=window.location;
    window.open('http://localhost/addurl.php?receivedurl='+unescape(loc)+'&receiveddesc='+tt,'BookMarkIt','menubar=no,status=no,location=no,width=300,height=300');history.goback()

    This all runs fine for normal urls but when I try to run this at the following url:

    http://groups.google.com/groups?hl=e....au%26rnum%3D3

    the value for receivedurl being passed to my destination is: http://groups.google.com/groups?hl=en

    so it stops at the & sign. Anyone with an idea how to solve this?

    thanks,

    geoffrey

  2. #2
    long gone but not forgotten AljapaCo's Avatar
    Join Date
    Aug 2001
    Location
    Sweden
    Posts
    548
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could try and use ascee for the & sign... & amp; (should be in one word but if I write like that you will only see a & sign)
    T O B I A S - S T R A N D H | visit my site here
    OPERA7 /MSIE6 /FireFox 1.1/Win2000 /ADSL /17" Screen /1024x768
    god doesn't create genius, he clones me.............

  3. #3
    SitePoint Member
    Join Date
    Apr 2002
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok i have been stupid,

    off course my page returns only the first submitted data, cause when the & sign means the next variable is to be defined ....

    no javascript stupidity, but developer interpretation stupidity..but thanks anyway

  4. #4
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Technically, you should be using "window.location.href" instead of just "window.location". The latter is an object, not a property, but some browsers are aware of bad code which attempts to use it as a property, and so returns the expected URL. This should not be relied upon, and is bad code. See the W3C specs.


    M@rco

  5. #5
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    just a quick Q, what about

    PHP Code:
    window.location.replace 

  6. #6
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That does something similar, but whereas the "window.location.href=" approach will navigate normally and allow you to return to the page that you were via the history (i.e. the "Back" button), the ".replace()" method replaces the current page in the history, and thus the page that it replaced cannot be returned to in the usual way.

    It is often useful to use this method to make sure that forms which have been submitted are not accidentally resubmitted by an impatient user.


    M@rco

    EDITED: typos everywhere, must go to bed...!
    Last edited by M@rco; Apr 15, 2002 at 19:28.

  7. #7
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was wondering the difference cheers


Bookmarks

Posting Permissions

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