Jump to content

PHP in JS


manalnor

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.