Jump to content

Recommended Posts

Hello friends,

 

let say we have an file called x.php and y.php and z.php

 

1) x.php is just any code like input form

 

2) y.php file with following code (iframe to x.php)

 

<?php
echo "<IFRAME FRAMEBORDER=0 ALIGN=CENTER width=100% HEIGHT=100% SCROLLING=no SRC=\"x.php\"></IFRAME>";
?>

 

and i want to add y.php into z.php as JS like this

 

<script type="text/javascript" src="y.php"></script>

 

i've tried all ways but it not working why !

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/232387-php-in-js/
Share on other sites

File Y is not a JS file.

 

okay thanks for hint, now its working

 

i've modified it to be

 

y.php

<?php
header("Content-type: text/javascript");
$site_root = "site-path";
?>
var script_path = "<?=$site_root?>";
document.writeln("<IFRAME FRAMEBORDER=0 ALIGN=CENTER width=100% HEIGHT=100% SCROLLING=no SRC=\"" +  script_path + "/x.php\"></IFRAME>");

Link to comment
https://forums.phpfreaks.com/topic/232387-php-in-js/#findComment-1195432
Share on other sites

Is that working?

I'm not sure if you can use any other extension for JavaScript files.

If it doesn't work, in index.php just do:

<script type="text/javascript">
var site_path = "<?=$site_root;?>";
</script>
<script type="text/javascript" src="y.js"></script>

 

y.js

// JavaScript Document
document.writeln('<IFRAME FRAMEBORDER="0" ALIGN="CENTER" width="100%" HEIGHT="100%" SCROLLING="no" SRC="' +  script_path + 'x.php"></IFRAME>');

 

Give that a shot

Link to comment
https://forums.phpfreaks.com/topic/232387-php-in-js/#findComment-1195436
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.