48 users online (0 members and 48 guests)  


  Results 1 to 6 of 6

Related

  1. iframe prints onlt the first page    Forum: HTML Forum
    Replies: 1
  2. html Iframe problem    Forum: HTML Forum
    Replies: 4
  3. HTML iframe Question    Forum: HTML Forum
    Replies: 5
  4. Replies: 7
  5. calling html dynamically    Forum: Website Scripts Forum
    Replies: 1
  1. #1
    winokur's Avatar
    New User

    Status
    Offline
    Join Date
    Jan 2010
    Posts
    2

    Calling PHP on HTML page with Iframe

    I have a page "index.html" which is generated by a back-end tool. I would like that page to use PHP to detect the type of browser viewing my site. I have working PHP code but for several reasons I cannot use PHP on this HTML page (the server doesn't support PHP on HTML). <p>

    I would like to use iFrame to call a static PHP page into this HTML page. Can someone tell me what html I need for my index page to run the php code on a separate page called detect.php ???
    <p>
    Thanks for helping out a rookie.
    <p>
    -Michael

    p.s. Here is the PHP in question:

    <?php

    include('mobile_device_detect.php');

    mobile_device_detect(true,true,true,true,true,true,' http://www.winokurphotography.com/mobile',false);

    ?>

  2. #2
    jthayne's Avatar

    Status
    Offline
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    508

    Re: Calling PHP on HTML page with Iframe

    Quote Originally Posted by winokur View Post
    the server doesn't support PHP on HTML
    It is very rare to find a server that supports PHP on an HTML page. The reason for this is that it would pretty drastically slow down your site since every HTML page would then have to pass through the PHP interpreter.

    Quote Originally Posted by winokur View Post
    I would like to use iFrame to call a static PHP page into this HTML page.
    Is there any reason you cannot change the page from index.html to index.php? This would be much simpler.

    Quote Originally Posted by winokur View Post
    Can someone tell me what html I need for my index page to run the php code on a separate page called detect.php ???
    I will have to look at it. What is the PHP code supposed to do once it finishes running? The answer to this will help determine whether or not you can do what you are asking in an iframe.

  3. #3
    winokur's Avatar
    New User

    Status
    Offline
    Join Date
    Jan 2010
    Posts
    2

    Re: Calling PHP on HTML page with Iframe

    JThayne,

    Thanks for thinking about this. The PHP code figures out what kind of browser (e.g. mobile device vs. firefox or ie) is looking at the site and then redirects mobile users to a non-flash version of the site. The code I showed on my post talks to another php page. You can see more about the code I'm working with here: http://detectmobilebrowsers.mobi/

    best,

    Michael

  4. #4
    HTML's Avatar
    Administrator

    Status
    Offline
    Join Date
    Aug 2000
    Posts
    3,445

    Follow HTML On Twitter Add HTML on Facebook Add HTML on Google+ Add HTML on Linkedin Visit HTML's Youtube Channel

    Re: Calling PHP on HTML page with Iframe

    Is there any reason why the page cannot be index.php?
    AHFBWEB Less customers per server, more power for you!

    Business Class Shared Hosting

  5. #5
    jthayne's Avatar

    Status
    Offline
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    508

    Re: Calling PHP on HTML page with Iframe

    The redirect is the key. It is possible to do this via an iframe, but it is very difficult and unreliable.

    The reason this is the case is that an iframe in essence works like a browser, so a redirect will only redirect what is within the iframe. Javascript can produce the effect you are looking for, but since all browsers interpret javascript differently (especially what is required for this to function), it is unreliable between browsers. Mobile browsers are some of the worst, and many of them dont' do so hot at supporting iframes.

    Again the question must be asked: Is there any reason you cannot rename index.htm to index.php?

    Also, I am assuming you have access to the .htaccess file. Is this correct?

  6. #6
    markei's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2009
    Location
    Westminster, MD
    Posts
    19

    Re: Calling PHP on HTML page with Iframe

    There is a site called detectmobilebrowser.com where you can either make a link using the form (enter mobile vs non-mobile destinations and it will create a url for you) OR click the Download Scripts link and several script versions will appear that you can download and use (Apache/Asp/Javascript/PHP/...etc.)

    Hope it helps!



Tags for this Thread