1

Well, I'm working on Wordpress Theme and I've a very strange behavior.

When I put my jQuery script in script tag (anywhere on the site) it works like charm.

But when I try to link to a file with the same script, like:

<script src="address" type="text/javascript"></script> - it doesn't.

What's wrong? The link is VALID. The script was tested in the beginning but also at the end of a site (so that's no "on load" problem).

How to troubleshoot problems like that? Is there a way to debug JavaScript in Opera?

Can't provide a link.

Thanks

2
  • What do you put for address? Commented Nov 10, 2010 at 12:30
  • You need to show more code. Where are you doing this? What behaviour are you expecting? Commented Nov 10, 2010 at 12:30

6 Answers 6

2

a javascript file should ends with .js, probably path and especially file name is wrong

take a look at firebug (or opera console) if this get returns a 404 error

Sign up to request clarification or add additional context in comments.

Comments

1

Like @Fabrizio Calderan said, maybe the script URL is wrong? Or maybe because of lack of js extension server doesn't send proper mime type and browser has a problem with interpreting the file. Also if it's wordpress, you probably rewrite post's URLs somehow - if the script is in your domain's root directory you should put / before filename, if it's in a template directory try what @Nick Pyett proposed.

Yes, you can debug JavaScript in Opera - check out Opera Dragonfly

Comments

1

You need to use the wp_enqueue_script() function. More here http://codex.wordpress.org/Function_Reference/wp_enqueue_script

Comments

1

Unfortunately you all were wrong, the answer was:

$(something) works only inline and when embedded - Wordpress accepts only jQuery instead of the dollar sign, so everything works fine after changing all "$" to "jQuery" :)

Anyways thanks! :)

Comments

0

Assuming your script is a .js file, is in your template folder and the line is being included between the html head tags...

<script src="<?php echo get_bloginfo('template_url')?>/address.js" type="text/javascript"></script>

Check the trailing slash after the php because i can't remember if the function includes one off the top of my head.

Comments

0

If you go to View - Developer Tools and check Opera Dragonfly, you will see Dragonfly open in the bottom of the browser, which appears to have similar capabilities to Firebug for Firefox (DOM browser, Network monitor, Script debugger, etc). This may help you get to the root of your problem.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.