Buááá! Don´t do me that! Isn´t Jesf... but Gesf...!!
Joke!
Ok, that code you were using is to call a external .js file!
Why!? And... what usage would have!?
Well, theres no difference having the code in a external file or inside the html code, but if you have a lot of javascript code... it would be cleaner/better having it in another file!
Yes, it is to call javascript code.
Never forget this: Javascript is client-side scripting, unlike php witch is server-side scripting!
However, it´s possible to 'interact' with both (not directly), anyway you need to understand this concept and how it could be done.
Let´s say you would use php to do all you have to do before the page is loaded/shown!
For your particular case (sending stuff through url), let´s see two differente examples!
In this first, we will set a variable in server to be catch by javascript when the page is 'shown':
- Code: Select all
<?php
$name = 'Maria';
?>
// Will print Maria
<script language="JavaScript">
document.write("<?php echo $name; ?>");
</script>
<?php
// Contunie with the php code
?>
In this next, we will send a variable through url with javascript, to be catch by php when the pages gone to be loaded in server (example):
- Code: Select all
<?php
/*
This php code will be loaded just if a variable section is passed through url, don´t matter the scripting language!
*/
if(isset($_GET['word'])){
echo $word; // Output maria
}
?>
<script language="JavaScript">
window.location.replace("http://www.yoursite.com/thisfile.php?word=maria");
</script>
// Contunie with code
Well, hope you understand, maybe this isn´t the best example.
See this related post !
Anyway, for your last post, can you show/tell me what you´re planning to do!?
Cheers,
Gesf