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

HTML meta tag > PHP variable

Expand Messages
  • 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
    Message 1 of 6 , Sep 2 2:31 PM
    • 0 Attachment
      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.

      ----------------------------------------------------------------------
      Get a free email account with anti spam protection.
      http://www.bluebottle.com/tag/2
    • soren.j.winslow@cummins.com
      I do not think it is possible. PHP is server-side that is processed before the page is rendered by the browser. JavaScript is processed after the page is
      Message 2 of 6 , Sep 4 10:49 AM
      • 0 Attachment
        I do not think it is possible. PHP is server-side that is processed before
        the page is rendered by the browser. JavaScript is processed after the
        page is rendered by the browser. So, you would not be able to change any
        of the PHP variable values after the page has been displayed, but you can
        change most things with JavaScript after the page has been displayed.

        Soren





        Stewart Buckingham <gaffer@...>
        Sent by: JavaScript_Official@yahoogroups.com
        09/04/2007 04:38 PM
        Please respond to
        JavaScript_Official@yahoogroups.com


        To
        JavaScript_Official@yahoogroups.com
        cc

        Subject
        [JavaScript] HTML meta tag > PHP variable






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







        [Non-text portions of this message have been removed]
      • Ian Smith-Dahl
        I m not completely understanding what you want to do, so forgive me if I m off-base here. Also, sorry for the slightly off-topic post here - I m not going
        Message 3 of 6 , Sep 4 2:47 PM
        • 0 Attachment
          I'm not completely understanding what you want to do, so forgive me
          if I'm off-base here. Also, sorry for the slightly off-topic post
          here - I'm not going to say much about JavaScript in this reply, but
          I'm trying to answer this man's question.

          Soren is right that you can't easily affect the PHP from JavaScript
          (change a php variable with your JavaScript)... although you can use
          AJAX if you need to.

          But why don't you do it all in PHP?

          If I understand you correctly, you want to use one page on multiple
          domains, but have the page title reflect the appropriate domain.
          The page will be a "for sale" page -- I assume that you are actually
          selling these domains, so the "for sale" page has to be the index.php
          file

          One of the environmental variables in PHP is $_SERVER... it's an
          array that holds a lot of useful information about the server that
          your file is running on. So you could make one php file with, for
          example:

          <title><?=$_SERVER['SERVER_NAME']> for sale!</title>

          If this line was executed in http://www.example.com/index.php, then
          it would echo "www.example.com for sale!" into the HTML title.

          There are a couple of other ways to do something similar with pure
          PHP (you could embed the variable in a POST or GET; you could read
          the request headers directly, or using the curl library) etc.
          Unless you have a compelling reason to use JavaScript that I'm just
          missing, you should take this question to a PHP email list.


          On Sep 2, 2007, at 5:31 PM, Stewart Buckingham wrote:

          > 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.
          >
          > ----------------------------------------------------------
          > Get a free email account with anti spam protection.
          > http://www.bluebottle.com/tag/2
          >
          >
          >



          [Non-text portions of this message have been removed]
        • Ian Smith-Dahl
          On second thought, you could also go pure JavaScript, couldn t you? something like: document.title = document.URL + on sale! ; Maybe I m not understanding
          Message 4 of 6 , Sep 4 3:00 PM
          • 0 Attachment
            On second thought, you could also go pure JavaScript, couldn't you?

            something like:
            document.title = document.URL + " on sale!";


            Maybe I'm not understanding what you need to do...


            On Sep 2, 2007, at 5:31 PM, Stewart Buckingham wrote:

            > 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.
            >
            > ----------------------------------------------------------
            > Get a free email account with anti spam protection.
            > http://www.bluebottle.com/tag/2
            >
            >
            >



            [Non-text portions of this message have been removed]
          • 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
            Message 5 of 6 , Sep 4 4:38 PM
            • 0 Attachment
              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
            • Paul Donahue
              Hi Stewart, I m not entirely clear on what you need. The meta tag array can be accessed via Javascript like this: var myArray =
              Message 6 of 6 , Sep 4 5:33 PM
              • 0 Attachment
                Hi Stewart,

                I'm not entirely clear on what you need. The meta tag array can be
                accessed via Javascript like this:

                var myArray = document.getElementsByTagName('meta');
                for(var i in myArray){
                document.write('Meta name = ' + myArray[i].name +
                ' Meta content = ' + myArray[i].content);
                }

                With PHP you can access the superglobal SERVER and get the data of
                where the user came from (if the browser sent it).

                <?php
                echo $_SERVER['HTTP_REFERER'];
                ?>

                If you really need to call a PHP script from Javascript it can be
                done:

                <script language='javascript'
                type='text/javascript'
                src='myExternalPhp.php'></script>

                Then whatever gets echoed from PHP needs to be valid javascript
                syntax with the appropriate header content type:

                <?php
                // myExternalPhp.php
                header('content-type: application/x-javascript');
                echo "document.write('Hello from PHP via Javascript');";
                ?>

                Paul



                --- In JavaScript_Official@yahoogroups.com, Stewart Buckingham
                <gaffer@...> wrote:
                >
                > 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.
                >
                > --------------------------------------------------------------------
                --
                > Get a free email account with anti spam protection.
                > http://www.bluebottle.com/tag/2
                >
              Your message has been successfully submitted and would be delivered to recipients shortly.