/    Sign up×
Community /Pin to ProfileBookmark

[Help!] Write PHP to document via JS!

I am trying to write some PHP code via JavaScript to my document, but it seems like the PHP is overriding the JS.

[code=php]document.write(‘<html><?php include(‘+file+’); ?></html>’);[/code]

You see the the text that turns red right? It overrides the JS. I really hope there is a solution for this.

/HaxxBlaster

to post a comment
JavaScript

13 Comments(s)

Copy linkTweet thisAlerts:
@A1ien51Nov 10.2006 — You need to learn the page life cycle.

Adding a php tag after the page has loaded is not going to do you any good.

If you need user content and server content, you should look into Ajax.

Eric
Copy linkTweet thisAlerts:
@HaxxBlasterauthorNov 10.2006 — You don't know what i am doing. Don't judge quick, i just posted the part i am having problem with.

Please help me instead.
Copy linkTweet thisAlerts:
@A1ien51Nov 10.2006 — Hey kid, I am here to help you and I DO KNOW what I am talking about. You need to learn about the page life cycle of an application,. PHP will not fire after the page has loaded so adding the tag with document.write will do you no good.

Have fun wasting your time if you think you can do it.

Eric
Copy linkTweet thisAlerts:
@mjdamatoNov 10.2006 — Haxx,

If the JavaScript is running on the client side, then there is no way for the PHP code to be run by the file server. Here is the process:

  • - User requests a page from the server

  • - If the file has the extension for a dynamic page (php, asp, etc) then the file is processed by the server. The output from this processing is then sent to the user

  • - Once the user receives the page, then the client-side javascript is run. If and php is written to the page at this point, the server cannot run it.


  • Now, it *might* be possible to run server-side Javascript and write the PHP to the page to be rendered - but that would make no sense as this would have to happen before the user receives the page.
    Copy linkTweet thisAlerts:
    @HaxxBlasterauthorNov 11.2006 — The answer "PHP will not fire after the page has loaded" is enugh. I know the rest.

    A PHP pro told me to use the PHP function include(), i wasted hours on this ****, i'm ****ing mad now.

    Check out what i'm doing at [URL=http://getc.awardspace.com/php]http://getc.awardspace.com/php[/URL], original site without PHP at [URL=http://getc.webb.se]http://getc.webb.se[/URL]. Why i was told to use include() was because IE could not use a transparent background in iframes.
    Copy linkTweet thisAlerts:
    @konithomimoNov 11.2006 — Why i was told to use include() was because IE could not use a transparent background in iframes.[/QUOTE]

    If you do not use a correct DOCTYPE then IE can have some quirky behaviour. To fix this you can either declare a DOCTYPE or use CSS to set the background-color to transparent.

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

    "http://www.w3.org/TR/html4/loose.dtd">

    or

    background-color: transparent;

    Then you simply need to use the allowtransparency attribute. Once you do that then IE will allow transparent background instead of a white background.
    Copy linkTweet thisAlerts:
    @HaxxBlasterauthorNov 11.2006 — Thank you!

    Actually, i tryed this before, and it diden't worked, but i guess i spelled it wrong.

    How sad, spended many hours of making such crap that never even would work! This makes me mad.
    Copy linkTweet thisAlerts:
    @konithomimoNov 11.2006 — Sure thing.
    Copy linkTweet thisAlerts:
    @bathurst_guyNov 12.2006 — Your page looks wrong in Safari too.

    [upl-file uuid=2da86292-bf00-4cc4-a311-b342b4de93a0 size=72kB]get-c.jpg[/upl-file]
    Copy linkTweet thisAlerts:
    @HaxxBlasterauthorNov 12.2006 — Thanks for mention it. I will fix it.

    But anyway, "background-color:transparent;" diden't took any effect at all on InternetExplorer!

    Just check yourself @: [URL=http://getc.webb.se/]http://getc.webb.se/[/URL]

    Look closely at the white frame, you will notice the difference.

    Why be so sure when it does not work?
    Copy linkTweet thisAlerts:
    @konithomimoNov 12.2006 — Read the entire post:

    "Then you simply need to use the allowtransparency attribute. Once you do that then IE will allow transparent background instead of a white background."


    That and you link to style.css and functions.js, but when I went to look at them they didnt show up. . . so you either have the permissions for them changed or they areny there
    Copy linkTweet thisAlerts:
    @HaxxBlasterauthorNov 13.2006 — Ok, but it don't really make a difference, because you should not have to change your settings to view the site correctly. It should be default.
    Copy linkTweet thisAlerts:
    @konithomimoNov 13.2006 — What are you talking about changing settings? allowtransparency is an attribute of a i/frame, thus if you add:

    allowTransparency="true"

    to your i/frame tag then it will work. It has nothing to do with changing any settings.
    ×

    Success!

    Help @HaxxBlaster spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.19,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...