他のHTMLページからJavaScript関数(オブジェクト内にある.jsファイル内)を呼び出す際に問題があります。コード例では、単純なHello World関数を使用します。jsファイルの外でJavaScript関数を呼び出す
//.js file window.addEvent('domready',function(){ var Site = { //Here I have like three other functions //This function I want to detect the browser version. I use MooTools for this detectBrowser : function(){ if(Browser.ie){ //Then what ever content goes here } } } //I execute the other three functions here because they need to be called on every page Site.dropdownmenu(); Site.accordion(); Site.lightbox(); });
私はMoodToolsで作業していますので、私はdomready関数の中にすべてを書きました。
今、cetect
関数はをのみ1ページで実行します。私はこのように何とかしようとしました:
//In the HTML file between two script tags: Site.alert();
それは動作しません。何か案は?
.jsファイルで実行するとうまく動作します。しかし私はすべてのページでそれを実行したくありません。
アラートは標準的なJavaScript関数なので、開始のために何か別のものを呼び出す – cusimar9
何が間違っているかを誰かが知るために十分なコードを掲載していません。 – Pointy
私たちに(非)実例を示してください。 – SLaks