Current location: Hot Scripts Forums » Programming Languages » PHP » how can i use javascript in PHP


how can i use javascript in PHP

Reply
  #1 (permalink)  
Old 01-25-04, 09:22 AM
sfaizanh sfaizanh is offline
New Member
 
Join Date: Jan 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
how can i use javascript in PHP

hey guys i need help with php how can i use javascript with php?

i want this code to use in PHP

<script language="Javascript1.2"><!-- // load htmlarea
_editor_url = ""; // URL to htmlarea files
var win_ie_ver = parseFloat(navigator.appVersion.
split("MSIE")[1]);
if (navigator.userAgent.indexOf('Mac') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Opera') >= 0) { win_ie_ver = 0; }
if (win_ie_ver >= 5.5) {
document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
document.write(' language="Javascript1.2"></scr' + 'ipt>');
} else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
// --></script>


i want this code in PHP nuke thx
html\admin\modules\stories.php
Reply With Quote
  #2 (permalink)  
Old 01-25-04, 12:28 PM
TemplatesForAll TemplatesForAll is offline
Newbie Coder
 
Join Date: Aug 2003
Location: Tucson, Arizona
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Not sure what you want, but here are 2 quick ways:
Code:
Some php code
?>

<script language="Javascript1.2"><!-- // load htmlarea
_editor_url = ""; // URL to htmlarea files
var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
if (navigator.userAgent.indexOf('Mac') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Opera') >= 0) { win_ie_ver = 0; }
if (win_ie_ver >= 5.5) {
document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
document.write(' language="Javascript1.2"></scr' + 'ipt>'); 
} else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
// --></script>

<?
More php code
or you can use this:
PHP Code:

 print( "<script language=\"Javascript1.2\"><!-- // load htmlarea\n" );

  print( 
"_editor_url = \"\"; // URL to htmlarea files\n" );
  print( 
"var win_ie_ver = parseFloat(navigator.appVersion.split(\"MSIE\")[1]);\n" );
  print( 
"if (navigator.userAgent.indexOf('Mac') >= 0) { win_ie_ver = 0; }\n" );
  print( 
"if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }\n" );
  print( 
"if (navigator.userAgent.indexOf('Opera') >= 0) { win_ie_ver = 0; }\n" );
  print( 
"if (win_ie_ver >= 5.5) {\n" );
  print( 
"document.write('<scr' + 'ipt src=\"' +_editor_url+ 'editor.js\"');\n" );
  print( 
"document.write(' language=\"Javascript1.2\"></scr' + 'ipt>'); \n" );
  print( 
"} else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }\n" );
  print( 
"// --></script>" ); 
__________________
-Scott
Templates For All - Free website templates.
FastBanner - Free PHP banner generator for your website.
Reply With Quote
  #3 (permalink)  
Old 01-25-04, 12:33 PM
sfaizanh sfaizanh is offline
New Member
 
Join Date: Jan 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Re: how can i use javascript in PHP

hey i want this codes to use in PHPNuke file
Reply With Quote
  #4 (permalink)  
Old 01-25-04, 01:31 PM
blaw's Avatar
blaw blaw is offline
Junior Code Guru
 
Join Date: Dec 2003
Location: Vancouver, BC, Canada
Posts: 550
Thanks: 0
Thanked 0 Times in 0 Posts
Hi there,

TemplatesForAll, I guess sfaizanh wants to have the same effect as the JavaScript he/she posted here in PHP.

I'm not a Nuke user and can't really help you how to integrate this into your Nuke, but there are some things you may want to know:

1) You cannot excute JavaScript before PHP, simply because PHP codes get excuted before HTML and JavaScript is loaded at the same time as HTML (more or less).

2) If you are interested in sniffing the visitors' user agent, etc, the counterpart in PHP for this is $_SERVER array. Check this out:

http://ca3.php.net/manual/en/reserve...riables.server

Hope this gives you some idea.
__________________
Blavv =|
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
execute php into javascript function Hagoromo PHP 3 05-23-07 02:19 AM
Reaaly stuck about javascript over frames muratisik JavaScript 1 12-14-03 11:58 AM
php and javascript together? gamextremer2003 PHP 5 11-06-03 02:18 PM
PHP to JAVASCRIPT: 2D Array Conversion 770 PHP 4 11-05-03 02:47 PM
Javascript vs PHP, problem with arrays Chuff JavaScript 0 10-03-03 04:01 AM


All times are GMT -5. The time now is 07:59 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.