Loading ...
Sorry, an error occurred while loading the content.
 

Re: [JavaScript] HTML meta tag > PHP variable

Expand Messages
  • Tim Sabin
    I wouldn t use the meta tag. What I d do: I d have the domains set a hidden field - say, domain . This could be included in your HTML:
    Message 1 of 3 , Sep 4, 2007
      I wouldn't use the meta tag. What I'd do:

      I'd have the domains set a "hidden" field - say, "domain". This could
      be included in your HTML:

      <input type="hidden" name="domain">

      Then. JavaScript can access the contents of "domain" easily:

      var domain; // Declare the variable
      domain = document.domain.value;

      How you transform this into PHP is beyond me.

      --Tim Sabin



      > Is it possible to turn an HTML meta tag into a PHP variable using
      > javascript?
      >
      > I want to turn the Page Title metatag into a PHP variable which I can
      > then echo to the screen. The Page Title is being forwarded to the
      page
      > by the domain (many domains are being forwarded to the same page and
      I
      > want to personalize the page by capturing the domain name which I've
      > entered into each domain's forwarding title metatag). It's basically
      a 1
      > page For Sale page for use by many domains.
      >
      > I'm not an expert in javascript. I considered this solution as a way
      to
      > get the domain name from the
      > incoming link. If there is a cleaner option available using
      javascript
      > (or anything else) to capture the domain name from the incoming link,
      > I'd be happy to use that instead, as it would not require me to edit
      > every domains records adding the page title tags 3 times for each
      domain
      > (www, @, and *), for many domains.
      >
      > ---------------------------------------------------------------------
      -
      > Find out how you can get spam free email.
      > http://www.bluebottle.com/tag/3
      >
      >
      >
      > Visit http://aiaiai.com for more groups to join
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
    • listgroups@ozwebwiz.com
      ... From: Stewart Buckingham Is it possible to turn an HTML meta tag into a PHP variable using javascript? I want to turn the Page Title metatag into a PHP
      Message 2 of 3 , Sep 4, 2007
        ----- Original Message -----
        From: Stewart Buckingham

        Is it possible to turn an HTML meta tag into a PHP variable using
        javascript?

        I want to turn the Page Title metatag into a PHP variable which I can
        then echo to the screen. The Page Title is being forwarded to the page
        by the domain (many domains are being forwarded to the same page and I
        want to personalize the page by capturing the domain name which I've
        entered into each domain's forwarding title metatag). It's basically a 1
        page For Sale page for use by many domains.

        I'm not an expert in javascript. I considered this solution as a way to
        get the domain name from the
        incoming link. If there is a cleaner option available using javascript
        (or anything else) to capture the domain name from the incoming link,
        I'd be happy to use that instead, as it would not require me to edit
        every domains records adding the page title tags 3 times for each domain
        (www, @, and *), for many domains.

        ----------------------------------------------------------

        I am not understanding what you want to achieve but yes it can be done.

        AJAX like scripting allows the passing of information between PHP and
        JavaScript however there is no need to learn AJAX as some simple scripting
        can be used in most cases. XML is bulky to work with and there are much
        simpler ways.

        Even so, it seems that what you want is even simpler again. I don't see
        where PHP comes into your problem. Perhaps all could be done on the client
        in JavaScript.

        Please give us an example of what you want to achieve.
      • David Smart
        I don t use PHP so am drawing on ASP experience here, but ... I think you are talking about some JavaScript in the DESTINATION page to extract the information
        Message 3 of 3 , Sep 5, 2007
          I don't use PHP so am drawing on ASP experience here, but ...

          I think you are talking about some JavaScript in the DESTINATION page to
          extract the information from the title tag and put it somewhere else so PHP
          can use it. Won't happen. The submit will go to the server, and it's the
          PHP code that will run. Any JavaScript in that page will not run until the
          server has sent the page to the browser for display.

          You could certainly put some JavaScript code in the SOURCE pages to grab the
          title and put it into a hidden field in the form either at page load time,
          or as part of the OnSubmit event. But this code will need to go into every
          source page, so is of dubious advantage over just putting the field in the
          form in the HTML in the first place.

          Have a look at how much of the source page the PHP gets to see. There is
          certainly some information bundled into the submit with the form (e.g.
          cookies) and the title of the source page might actually go to the PHP
          anyway. An alternative would be to look at the URL of the source page (I
          think that goes across) and parse the required information out of it.

          If you haven't already, you should also ask this question on a PHP group.

          Regards, Dave S

          ----- Original Message -----
          From: "Stewart Buckingham" <gaffer@...>
          To: <JavaScript_Official@yahoogroups.com>
          Sent: Wednesday, September 05, 2007 9:38 AM
          Subject: [JavaScript] HTML meta tag > PHP variable


          > Is it possible to turn an HTML meta tag into a PHP variable using
          > javascript?
          >
          > I want to turn the Page Title metatag into a PHP variable which I can
          > then echo to the screen. The Page Title is being forwarded to the page
          > by the domain (many domains are being forwarded to the same page and I
          > want to personalize the page by capturing the domain name which I've
          > entered into each domain's forwarding title metatag). It's basically a 1
          > page For Sale page for use by many domains.
          >
          > I'm not an expert in javascript. I considered this solution as a way to
          > get the domain name from the
          > incoming link. If there is a cleaner option available using javascript
          > (or anything else) to capture the domain name from the incoming link,
          > I'd be happy to use that instead, as it would not require me to edit
          > every domains records adding the page title tags 3 times for each domain
          > (www, @, and *), for many domains.
          >
          > ----------------------------------------------------------------------
          > Find out how you can get spam free email.
          > http://www.bluebottle.com/tag/3
          >
          >
          >
          > Visit http://aiaiai.com for more groups to join
          > Yahoo! Groups Links
          >
          >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.