#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Ye Olde England
    Posts
    80
    Rep Power
    15

    Question Javascript question mark question?


    Hi,

    I am making a simple function that creates the relevant query string and then opens a window that goes to that URL with the query string:

    Code:
       function preview() {
          var temno, querystr, url;
          temno = document.templateform.addtemplate.selected;
          querystring = "?" + "template=" + temno;
          url = 'template_preview.sss' + querystring;
          window.open(url, "PreviewWin");
        }
    The problem is with the question mark. I have tried to unescape the question mark's escaped code but it still doesn't work!!!

    Code:
       function preview() {
          var temno, querystr, url;
          temno = document.templateform.addtemplate.selected;
          querystring = unescape("%3F") + "template=" + temno;
          url = 'template_preview.sss' + querystring;
          window.open(url, "PreviewWin");
        }
    How come neither of the above work when if you replace the question mark with anything else it does???

    Thanks

    Tajmiester
  2. #2
  3. Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Location
    London, UK
    Posts
    4,005
    Rep Power
    2795
    I have just tried just about every method under the sun and I cannot find a solution to this.

    I'm surpised that I have not come across it before actually. I'd be interested in seeing how someone tackles this.
  4. #3
  5. Thanks Johnny Hart (BC) R.I.P.

    Join Date
    May 2003
    Location
    Dallas
    Posts
    5,262
    Rep Power
    1960
    I may be showing my as ^H^H ignorance here, but don't you want to "escape" the "?"?
    Code:
    querystring = "?" + "template=" + temno;
    
    becomes
    
    querystring = escape(?) + "template=" + temno;
    or whatever the correct syntax is?

    cheers,

    gary
    There are those who manage to build a web site without knowing what they're doing; thereby proving to themselves they do, indeed, know what they're doing.

    My html and css workshop, demos and tutorials.
    Ask a better question, get a better answer.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Ye Olde England
    Posts
    80
    Rep Power
    15
    I have tried that in my desperation but that is not what the escape function does. The escape function goes from '?' to '%3F' and unescape goes back. I have not found a way of doing the javacript equivilant of this "\?" in Perl. When I unescape %3F and assign it to a text box it works and appears as a question mark, but when I use it as a URL it doesn't. Further more any combination of a question mark with any other string seems to 'taint' or invalidate the string. You would expect that even if the ? didnt work you would output this:

    template_preview.ssstemplate=1

    but no, all it outputs is

    template_preview.sss

    HELP?

    Tajmiester
    Thanx Tajmiester.

IMN logo majestic logo threadwatch logo seochat tools logo