Re: newbie questions (2) : Detect presence of plugin/ActiveX viaPHP3? and Linked PHP scripts?

From: Date: Tue, 29 Aug 2000 14:08:59 +0000
Subject: Re: newbie questions (2) : Detect presence of plugin/ActiveX viaPHP3? and Linked PHP scripts?
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-2263@lists.php.net to get a copy of this message
brian donovan wrote: > Hello, > > I'm just starting to learn php, so please forgive me if this is a > retarded question, but I was wondering if it is possible to detect whether a > plugin and/or ActiveX control is installed on a user's machine via php3 when > they visit a site. I don't have a good answer to this first question... sorry, but others may know more on this one :) > My second question is - is it possible to include php scripts in a page > through some sort of linking, in a way analogous to how external javascripts > can be included - ie <script type="text/javascript" > src="crappyscript.js"></script>? Well, you've basically just written this yourself... your hunch was correct. I'm doing this currently and it works like a charm, allowing plain HTML pages (for users with javascript-enabled browsers) to load dynamic content from other scripts. Here's how I'm doing it: In my HTML page, I have a single script line where I want the dynamic content to be loaded... <script language="javascript" src="myscriptgenerator.php"></script> NOTE: it doesn't matter that the src tag ends in ".php", since we'll be *faking* the browser out in a moment. Now, have your PHP script (in this case myscriptgenerator.php), do everything it would normally do to create dynamic HTML content, BUT... when it comes to returning (printing, echoing, etc) content to the browser, simply WRAP your HTML output in javascript 'document.write()' calls... something like this... **** myscriptgenerator.php **** <?php # connect to database, or set vars yourself $onevar = "Hey World! How's it going?"; echo "document.write('<p>You made it. " . $onevar . " And the dynamic string just printed.</p>');\n"; ?> **** end myscriptgenerator.php **** What the browser sees when it loads the javascript source specified in the scr= tag is simply... document.write('<p>You made it. Hey World! How's it going? And the dynamic string just printed.</p>'); ... which will then be output in the browser at the location of the <script> tag :) Hey, I like it! As long as your script returns valid javascript code, you're good to go! > Sorry for the dumb questions, but I'm just starting out with php. Much > thanks for your help. There are no dumb questions... mostly only dumb answers :) -- Andy Hoffman Web Developer Bristol-Myers Squibb email: andy.hoffman@bms.com

« previous php.windows (#2263) next »