SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Addict SLEE's Avatar
    Join Date
    Aug 2003
    Location
    uk
    Posts
    258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    javascript to php

    is there any way to pass the window location to php but not suing the query string?

    i need it to be passed without changing the page.

  2. #2
    Maniacally depressed robot poncho's Avatar
    Join Date
    Dec 2004
    Location
    Belfast, N.Ireland
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you mean the address of the current page, PHP can get that all by itself.
    Perfecting the art of breaking stuff.
    Check 'em: CakePHP | TextMate

  3. #3
    SitePoint Addict SLEE's Avatar
    Join Date
    Aug 2003
    Location
    uk
    Posts
    258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how? the problem i have its that the php file is on a server but the call is from a xul file running from a toolbar ive built as a firefox extension.

  4. #4
    Maniacally depressed robot poncho's Avatar
    Join Date
    Dec 2004
    Location
    Belfast, N.Ireland
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, I'm not sure what way XUL applications work. Sorry dude.
    Perfecting the art of breaking stuff.
    Check 'em: CakePHP | TextMate

  5. #5
    SitePoint Addict SLEE's Avatar
    Join Date
    Aug 2003
    Location
    uk
    Posts
    258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if it wasnt in a xul file how would you do it?

  6. #6
    Maniacally depressed robot poncho's Avatar
    Join Date
    Dec 2004
    Location
    Belfast, N.Ireland
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm thinking simple.

    PHP Code:
    echo "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; 
    For this page, that would output:
    Code:
    http://www.sitepoint.com/forums/showthread.php?p=2319834&posted=1
    Perfecting the art of breaking stuff.
    Check 'em: CakePHP | TextMate

  7. #7
    SitePoint Addict SLEE's Avatar
    Join Date
    Aug 2003
    Location
    uk
    Posts
    258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ye unfortunatly that wont work but thanks for trying.

    the file that will be doing the work will be on my website which the toolbar will access.
    so using your above code would return the same everytime.

    the xul file os just a file that will call the javascript or php file, i need some way of passing the url in the users browser through to the database so i can use it to do a query but i cant use a query string.

  8. #8
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you use AJAX to send the URL to the PHP script?
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  9. #9
    SitePoint Addict NikoB's Avatar
    Join Date
    Nov 2005
    Location
    Austria
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you should use ajax. try
    Code:
    req = new XMLHttpRequest();
    req.open('GET', 'http://your.server.tld/dbreq.php', true);
    req.setRequestHeader("X-Foo", "theurltotransmit");
    req.send(null);
    You can then use php to read the header X-Foo which contains the url of the window.

    also see http://www.xulplanet.com/references/...tpRequest.html (and the comments)
    Corinis OpenSource Community & Content Management
    http://www.corinis.org

  10. #10
    SitePoint Addict SLEE's Avatar
    Join Date
    Aug 2003
    Location
    uk
    Posts
    258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    would i need a seperate file to get the header?

  11. #11
    SitePoint Addict NikoB's Avatar
    Join Date
    Nov 2005
    Location
    Austria
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i am not sure what you mean, you can read the header using php...
    Corinis OpenSource Community & Content Management
    http://www.corinis.org

  12. #12
    SitePoint Addict SLEE's Avatar
    Join Date
    Aug 2003
    Location
    uk
    Posts
    258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how would i do that? im a newbie to some of this so its a bit mind numbing.

  13. #13
    SitePoint Addict NikoB's Avatar
    Join Date
    Nov 2005
    Location
    Austria
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Corinis OpenSource Community & Content Management
    http://www.corinis.org


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
  •