SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Thread: document.write

  1. #1
    SitePoint Evangelist
    Join Date
    Apr 2005
    Location
    London, UK
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    document.write

    Folks,

    in my html page within the head tags I have below js.

    PHP Code:
    document.write('<img src="http://www.foo.com?Email='+Email1+'&Address 1='+A11+'&Address 2='+A21+'&Birthdate='+DOB1+'&City='+CI1+'&First Name='+FirstName1+'&Gender1='+Gender+'&Last Name='+LastName1+'&Phone Number='+PH1+'&State='+ST1+'&Zip Code='+ZIP1+'" width="1" height="1">');
               
            
      
    setTimeout("location.href = 'http://www.foo.com?rid=" + (rid+FirstName+LastName+Email+Gender+DOB) + "&r="+(vRURL+A1+A2+CI+ST+ZIP+PH)+" ';",1500); 
    when I run the above in IE it redirects to whatever I have set in the setTimeout function, but on mozz it does not redirect. Mozz just get's stuck with the document.write in transferring data from foo.com back to me, but i only want it to do a document.write then move to setTimeout function.

    I have struggling to get this working. anyone any ideas please?

  2. #2
    Forums Designer
    Join Date
    Jun 2004
    Posts
    422
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try using encodeURIComponent() on URL parameters. Like this: ...?Email='+encodeURIComponent(Email1)+'&Addr...

    Also add / before ? to make a valid URL (though I'm not sure about this).

  3. #3
    SitePoint Evangelist
    Join Date
    Apr 2005
    Location
    London, UK
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by CyberAlien View Post
    Try using encodeURIComponent() on URL parameters. Like this: ...?Email='+encodeURIComponent(Email1)+'&Addr...

    Also add / before ? to make a valid URL (though I'm not sure about this).
    Dude thanks for your reply. That though wont solve it. The issue is such that on mozz it does the document.write, but it hangs and does not move on to setTimeout.

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Is it even valid for an image to be written to the head?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Evangelist
    Join Date
    Apr 2005
    Location
    London, UK
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    Is it even valid for an image to be written to the head?
    I have had this solved now.

    I'd say it's a dirty alternative of what I'm trying to do. I', simply trying to post the data contained in the document.write image to another url, the only way I was able to do this was through document.write image. I know there exists other way such DOM, but my javascript is crap. So if anyone knows a better way of posting to another url just before the setTimeout function happens let me know.

  6. #6
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ma201dq View Post
    I have had this solved now.

    I'd say it's a dirty alternative of what I'm trying to do. I', simply trying to post the data contained in the document.write image to another url, the only way I was able to do this was through document.write image. I know there exists other way such DOM, but my javascript is crap. So if anyone knows a better way of posting to another url just before the setTimeout function happens let me know.
    A typical way is for you to use a redirect page. That way, the redirect page performs the update that you require, and you can pass to that redirect page the name of the page that you want to redirect to, which can contain querystring info encoded within it as well.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  7. #7
    SitePoint Evangelist
    Join Date
    Apr 2005
    Location
    London, UK
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Paul,

    Are you speaking of pushing the data to a popup window?

  8. #8
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ma201dq View Post
    Paul,

    Are you speaking of pushing the data to a popup window?
    No, I'm speaking of using server-side code to do your action and to then perform the redirect for you.

    If you don't want to go that far, you can just make use use of an ajax request of the first location, before loading the second page.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  9. #9
    SitePoint Evangelist
    Join Date
    Apr 2005
    Location
    London, UK
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    No, I'm speaking of using server-side code to do your action and to then perform the redirect for you.

    If you don't want to go that far, you can just make use use of an ajax request of the first location, before loading the second page.
    had I had access to the server side code this would been bread and butter to do, but I don't; I only have access to the client-side of things.

    would you please care to show me how it is done using Ajax? I have been looking at an Ajax solution but could not get it to work.

  10. #10
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ma201dq View Post
    had I had access to the server side code this would been bread and butter to do, but I don't; I only have access to the client-side of things.

    would you please care to show me how it is done using Ajax? I have been looking at an Ajax solution but could not get it to work.
    Sure, the Bulletproof Ajax book has good code and examples to go along with the book's content.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


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
  •