[solved] JS doesn't work

Hello All.

Got a problem. I bind my .js file in the main.php

<script type="text/javascript" src="javascript/js.js"></script>

There i got a simple alert function

function hallo()




Now if i’m trying to use it on a site, it doesn’t work.

echo CHtml::submitButton('Upload', array('onclick'=>'hallo();'));

Can somebody help?

do i have to change something in the htmloptions?

where do you put your js file??

maybe the browser didn’t found your js.js file…

got my js file under the directory root in the folder javascript.


try out something different.

but it seems ur right. my server is not running right.

got an apache. local.

but waht do i have to change? thought that js is turned on automatically.


i thought Javascript is only running on clientside

My javascript is running well online. but offline with xampp, it doesn’t work. Don’t understand this 0o

hm… how about put this little php code in your javascript include?

<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl ?>/javascript/js.js"></script>

see whether it works

you’re right.

but why? because i’m using url manager?

Maybe. If the urlManager is activated, usually the url will something like this:

www.myweb.com/site/login (we hide the index.php)

the browser might really try to find a file with url at there(it go to folder names "login" in "site" folder). This is what I guess.

ok. so thanks! :)