sermon
(Mat Bl)
1
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()
{
alert("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?
junxiong
(Junxiong)
2
where do you put your js file??
maybe the browser didn’t found your js.js file…
sermon
(Mat Bl)
3
got my js file under the directory root in the folder javascript.
javascript/file.js
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.
EDIT:
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
junxiong
(Junxiong)
4
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
sermon
(Mat Bl)
5
you’re right.
but why? because i’m using url manager?
junxiong
(Junxiong)
6
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.