manalnor Posted April 1, 2011 Share Posted April 1, 2011 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 More sharing options...
j9sjam3 Posted April 1, 2011 Share Posted April 1, 2011 File Y is not a JS file. Link to comment https://forums.phpfreaks.com/topic/232387-php-in-js/#findComment-1195429 Share on other sites More sharing options...
manalnor Posted April 1, 2011 Author Share Posted April 1, 2011 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 More sharing options...
j9sjam3 Posted April 1, 2011 Share Posted April 1, 2011 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.