Shoutbox

Is there a way to include (in PHP) with javascript? - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: Is there a way to include (in PHP) with javascript? (/showthread.php?tid=26195)

Is there a way to include (in PHP) with javascript? by Art Crazy on 05-27-2004 at 08:20 PM

Is there a way to include something in a page like <?php include "bla";?> but in java script?


RE: Is there a way to include (in PHP) with javascript? by Banks on 05-27-2004 at 08:31 PM

include will take another file and basically act as if it was part of that page, so if you have a .js file yes, but i don't see why you wouldn't just use <script src="">


RE: Is there a way to include (in PHP) with javascript? by Art Crazy on 05-27-2004 at 08:33 PM

Sry but i know a little about coding.
how do i use <script src="">???


RE: Is there a way to include (in PHP) with javascript? by lhunath on 05-27-2004 at 08:37 PM

<script src="[uri-to-javascript-file]" />

Like, say you have some javascript in a file called MyJava.js
then you write
<script src="MyJava.js" language="javascript" type="text/javascript" />
And when the browser arrives at this line, it will parse the content of the javascript file refered to.

(Edit: added language/type attributes)


RE: Is there a way to include (in PHP) with javascript? by Art Crazy on 05-27-2004 at 08:40 PM

Ok thanks, now could u help me making an php or shtml file with include for a file named news.php?
If u explained me how to do one working..
mine doesnt work..


RE: Is there a way to include (in PHP) with javascript? by lhunath on 05-27-2004 at 08:50 PM

quote:
Originally posted by Art Crazy
Ok thanks, now could u help me making an php or shtml file with include for a file named news.php?
If u explained me how to do one working..
mine doesnt work..
Mind asking what you want me to do rather than pointing at a library and asking me to get me 'that' book for you.... ? If you get what I mean =)

Including is easy, as long as your server supports PHP.
add <?php include "[uri-to-file]"; ?> in your document. Make sure it has the extension .php instead of .html or so.. and you're ready. (Mind, it'll only run on the server, if it supports PHP, it won't work in your own pc if you preview it without uploading..)
RE: Is there a way to include (in PHP) with javascript? by lylesback2 on 05-27-2004 at 10:36 PM

<?
include("javafile.html")
?>


RE: Is there a way to include (in PHP) with javascript? by Guido on 05-27-2004 at 10:54 PM

quote:
Originally posted by lhunath
Make sure it has the extension .php instead of .html or so
Just to clarify, that's for the file where you place the include() code, the included file can be of any extension and it will be parsed as if it were a .php NO MATTER WHAT EXTENSION IT HAS.
RE: Is there a way to include (in PHP) with javascript? by lizard.boy on 05-28-2004 at 01:21 AM

exactly what guido said. i did this thing using dynamic css using an include and a file with css in it with variables lol.


RE: Is there a way to include (in PHP) with javascript? by CookieRevised on 05-28-2004 at 10:08 AM

quote:
Originally posted by lhunath
<script src="[uri-to-javascript-file]" />
Loose the "/" at the end, that is NOT valid html!!! That should only be used when you have a XHTML page...

RE: Is there a way to include (in PHP) with javascript? by fluffy_lobster on 05-28-2004 at 02:03 PM

Well you should be making your pages XHTML compatible anyway :P  All the main web browsers support it.


RE: Is there a way to include (in PHP) with javascript? by CookieRevised on 05-28-2004 at 03:13 PM

Who said that? It's not because (most) browsers support it, that you should use it... What is wrong with HTML? If you don't have a use for XHTML then why use it? XHTML is an extention to HTML... BTW, most pages I encountered on the web that claim to be XHTML don't even have a DTD specification and are just normal HTML pages (but with the error like /> in them)... So don't mix up standards ;)


To give examples:
For non-empty elements, end tags are required in XHTML. This means you can't use:
  <p>this is a line<p>this is a new line.
but you must use:
  <p>this is a line</p><p>this is a new line.</p>
This is not required in HTML. Now look at the source of this thread... It claims to be XHTML, but yet <p> is used without </p>.

Attribute values must always be quoted in XHTML. That's something many people forget. You can't use:
  <img with=100 height=100 src=http://blahblah>
but you must use:
  <img with="100" height="100" src="http://blahblah">
This is not required in HTML.

My whole point is, don't use XHTML if you don't need it. You don't use Flash either if you don't have a use for it ;)


RE: Is there a way to include (in PHP) with javascript? by fluffy_lobster on 05-28-2004 at 04:15 PM

From what I gather, there are various benefits of XHTML over HTML because it's an XML-compliant markup.  The purpose of using XHTML over HTML isn't so much that it enhances the page at all but it allows browsers to move on with the knowledge that more sites are now using XHTML.  Browsers would be a fair lot faster if they parsed only XHTML, not HTML

Plus, XHTML is GREAT for making conversation about :P


RE: Is there a way to include (in PHP) with javascript? by WDZ on 05-28-2004 at 05:14 PM

XHTML is the future! :p

quote:
http://www.w3.org/TR/xhtml1/#xhtml
The XHTML family is the next step in the evolution of the Internet. By migrating to XHTML today, content developers can enter the XML world with all of its attendant benefits, while still remaining confident in their content's backward and future compatibility.

MyBB was originally not XHTML, and is in the process of being "upgraded." When I create new things, I use XHTML, and I check it with an XHTML validator.

quote:
Originally posted by CookieRevised
For non-empty elements, end tags are required in XHTML. This means you can't use:
  <p>this is a line<p>this is a new line.
That's shitty anyway... you should always close your tags if you want clean, professional code. :dodgy: