• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

confusing about jquery loading in html

DaNcE-eViL

[H]ard|Gawd
Joined
Oct 31, 2001
Messages
1,128
im bit confuse atm regarding loading .js file see below:

in html tag - we use as the following code:

code1:

<script type="text/javascript" src="<?php echo $ServerURL?>Javascripts/basicgallery.js" charset="UTF-8"></script>

but i rather not to load above code1 but i'd like to load code2 below but it wont load properly but still work with code 1..

code2:

<script type="text/javascript">

jQuery(function ($) {
// Load dialog on page load
// Load dialog on click

$('#test-modalbox .basicSlideshow').click(function (e) {
$('#test-modalbox-content').modalbox();

return false;
});
});

</script>


any idea what im doing wrong
 
are you trying to run that function on page load?

you can run stuff using jquery on page load by wrapping it in a $(document).ready() {//code here }

and obviously you are loading/referencing the jquery.js?
 
are you trying to run that function on page load?

you can run stuff using jquery on page load by wrapping it in a $(document).ready() {//code here }

and obviously you are loading/referencing the jquery.js?

tried that and still doesn't work :confused:
 
For code 2 to work you need to load simplemodal and the jquery framework. Are you loading both before?
 
im bit confuse atm regarding loading .js file
code2:

<script type="text/javascript">

jQuery(function ($) {
// Load dialog on page load
// Load dialog on click

$('#test-modalbox .basicSlideshow').click(function (e) {
$('#test-modalbox-content').modalbox();

return false;
});
});

</script>

jQuery(function ($)) // Isn't $ supposed to contain a variable or left out entirely?

You could do: $(function(){}); instead I believe.
 
You can also do script like this at the bottom of your DOM.

<script>
function(){
....Code to be run at load.
}();
</script>

Putting the scripting at the end of your DOM will load it after the previous page elements (though this is not a reliable method). The () at the end of the anonymous function will cause that function to execute immediately when it's defined.
 
HTML:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<!--any other scripts-->
<script type="text/javascript">
      $(document).ready(function(){
            $('#test-modalbox .basicSlideshow').click(function (e) {
                $('#test-modalbox-content').modalbox();
                return false;
            });
        });
</script>
If this don't work you probably have a sintax error in the including script(s). (some cases it won't even appear in the browsers error log)
 
Last edited:
Back
Top