Start New Discussion Reply to this Discussion urgently required help
Hello
thanks for helping me before. I have a issue and I need its complete solution if someone can help me in this
I have a simple php which contains html script and which have iframe included in it. I want its java scrpt embedded code so that users can embed my this script into their pages (php external java script)
the script should be like this
<script type="text/javascript" src="ip.php"></script>
My html code is
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1" bgcolor="#FFFFFF">
<tr>
<td width="100%">
<iframe width="100%" scrolling="no" height="400" frameborder="0" src="http://localhost/pages/searching" name="I1"></iframe>
</td>
</tr>
<tr>
<td width="100%">
<p align="center"><font face="Arial" style="font-size: 6pt">
<a target="_blank" href="http://www.mywebsite.com" style="text-decoration: none">
<font color="#FFFFFF">My Website link</font></a></font></td>
</tr>
</table>
Please provide me the solution
hallianonline
Light Poster
28 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Can you write this question more clearly? It looks like your trying to include a PHP file through the <script> tags...
phper
Posting Whiz in Training
213 posts since Nov 2006
Reputation Points: 22
Solved Threads: 19
Skill Endorsements: 0
ok I mean to say that
this is my php script and I saved it on my server as mypage.php
<?php
<html>
<body>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1" bgcolor="#FFFFFF">
<tr>
<td width="100%">
<iframe width="100%" scrolling="no" height="400" frameborder="0" src="http://localhost/pages/searching" name="I1"></iframe>
</td>
</tr>
<tr>
<td width="100%">
<p align="center"><font face="Arial" style="font-size: 6pt">
<a target="_blank" href="http://www.mywebsite.com" style="text-decoration: none">
<font color="#FFFFFF">My Website link</font></a></font></td>
</tr>
</table>
</body>
</html>
?>
Now I want its external javascript code so that my users can us this code to add my page anywhere into their websites using this code
<script type="text/javascript" src="http://www.mywebsite.com/mypage.php"></script>
hallianonline
Light Poster
28 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
something like this
<?php
header("content-type: application/x-javascript");
echo "document.write('<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" width=\"100%\" id=\"AutoNumber1\" bgcolor=\"#FFFFFF\"><tr><td width=\"100%\">
<iframe width=\"100%\" scrolling=\"no\" height=\"400\" frameborder=\"0\" src=%22http:/localhost/pages/searching/%22 name=\"I1\"></iframe></td></tr><tr><td width=\"100%\"><p align=\"center\"><font face=\"Arial\" style=\"font-size: 6pt\">
<a target=\"_blank\" href=%22http:/www.mywebsite.com/%22 style=\"text-decoration: none\"><font color=\"#FFFFFF\">My Website link</font></a></font></td></tr></table>');";
?>
hallianonline
Light Poster
28 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
you include a php file using a javascript include tag? now that's weird man, php include() and require() are used in php to include files. so nevertheless what's the problem? what do you want to achieve?
vaultdweller123
Posting Pro
574 posts since Sep 2009
Reputation Points: 47
Solved Threads: 81
Skill Endorsements: 2
Why wouldn't you just get the user to add an IFrame to their page??
phper
Posting Whiz in Training
213 posts since Nov 2006
Reputation Points: 22
Solved Threads: 19
Skill Endorsements: 0
No I dont want to give iframe only I want to give them a js script code to use script on their web please provide me the solution
hallianonline
Light Poster
28 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
I don't see why you are using PHP at all here.
How about they just insert a javascript file?
They insert:
<script src="http://yoursite.com/mypage.js">
then in mypage.js:
<script>
document.write('<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" width=\"100%\" id=\"AutoNumber1\" bgcolor=\"#FFFFFF\"><tr><td width=\"100%\">
<iframe width=\"100%\" scrolling=\"no\" height=\"400\" frameborder=\"0\" src=%22http:/localhost/pages/searching/%22 name=\"I1\"></iframe></td></tr><tr><td width=\"100%\"><p align=\"center\"><font face=\"Arial\" style=\"font-size: 6pt\">
<a target=\"_blank\" href=%22http:/www.mywebsite.com/%22 style=\"text-decoration: none\"><font color=\"#FFFFFF\">My Website link</font></a></font></td></tr></table>');
</script>
PS: I copied the document.write function wholesale from hallianonline's helpful post, just removed the PHP echo. :P
jawanda0
Newbie Poster
11 posts since Feb 2012
Reputation Points: 13
Solved Threads: 3
Skill Endorsements: 0
hallianonline
Light Poster
28 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
In my page.js you don't need the <script> tags
phper
Posting Whiz in Training
213 posts since Nov 2006
Reputation Points: 22
Solved Threads: 19
Skill Endorsements: 0
then how can I use it? please tell me the solution
hallianonline
Light Poster
28 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Put the script that was between the script tags in your .js file. That's it. Don't forget wherever you include that js file is where that table will appear
phper
Posting Whiz in Training
213 posts since Nov 2006
Reputation Points: 22
Solved Threads: 19
Skill Endorsements: 0
In my page.js you don't need the <script> tags
the mypage.js is already a javascript file so you don't need the <script> tags. you can go ahead and write your code directly without this tag
agbenaza
Newbie Poster
18 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Right ok.
So you include the file:
<script type="text/javascript" src="filename.js"></script>
Contents of the included file (I've called it filename.js)
document.write('<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" width=\"100%\" id=\"AutoNumber1\" bgcolor=\"#FFFFFF\"><tr><td width=\"100%\">
<iframe width=\"100%\" scrolling=\"no\" height=\"400\" frameborder=\"0\" src=%22http:/localhost/pages/searching/%22 name=\"I1\"></iframe></td></tr><tr><td width=\"100%\"><p align=\"center\"><font face=\"Arial\" style=\"font-size: 6pt\">
<a target=\"_blank\" href=%22http:/www.mywebsite.com/%22 style=\"text-decoration: none\"><font color=\"#FFFFFF\">My Website link</font></a></font></td></tr></table>');
That's it - wherever you include the file using <script type="text/javascript" src="filename.js"></script> is where that table will be inserted. So if you include that script between the <HEAD> tags it won't be displayed (I don't think)
phper
Posting Whiz in Training
213 posts since Nov 2006
Reputation Points: 22
Solved Threads: 19
Skill Endorsements: 0
Yep, exactly.
Then once you get to this point, we'll deal with the fact that your embedded iFrame (within the table) is probably not going to work the way you want it to lol :)
Right ok.
So you include the file:
<script type="text/javascript" src="filename.js"></script>
Contents of the included file (I've called it filename.js)
document.write('<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" width=\"100%\" id=\"AutoNumber1\" bgcolor=\"#FFFFFF\"><tr><td width=\"100%\">
<iframe width=\"100%\" scrolling=\"no\" height=\"400\" frameborder=\"0\" src=%22http:/localhost/pages/searching/%22 name=\"I1\"></iframe></td></tr><tr><td width=\"100%\"><p align=\"center\"><font face=\"Arial\" style=\"font-size: 6pt\">
<a target=\"_blank\" href=%22http:/www.mywebsite.com/%22 style=\"text-decoration: none\"><font color=\"#FFFFFF\">My Website link</font></a></font></td></tr></table>');
That's it - wherever you include the file using <script type="text/javascript" src="filename.js"></script> is where that table will be inserted. So if you include that script between the <HEAD> tags it won't be displayed (I don't think)
jawanda0
Newbie Poster
11 posts since Feb 2012
Reputation Points: 13
Solved Threads: 3
Skill Endorsements: 0
so you just want to include your iframe on every page? well you don't have to use PHP to do that, a simple javascript can do the work
<html>
<head>
<script type="text/javascript" src="test2.js"></script>
</head>
<body>
</body>
</html>
test2.js
document.write("<table border='0' cellpadding='0' cellspacing='0' style='border-collapse:collapse' bordercolor='#111111' width='100%' id='AutoNumber1' bgcolor='#FFFFFF'><tr><td width='100%'><iframe width='100%' scrolling='no' height='400' frameborder='0' src='http://www.w3schools.com/' name='I1'></iframe></td></tr><tr><td width='100%'><p align='center'><font face='Arial' style='font-size: 6pt'><a target='_blank' href='http://www.w3schools.com/' style='text-decoration: none'><font color='#FFFFFF'>My Website link</font></a></font></td></tr></table>");
replace the sample url(i use w3schools :D) on the iframe's src and on anchor's href attribute with your own url
vaultdweller123
Posting Pro
574 posts since Sep 2009
Reputation Points: 47
Solved Threads: 81
Skill Endorsements: 2
© 2013 DaniWeb® LLC
Page rendered in 0.1179 seconds
using 2.84MB