2017-04-11 65 views
0

我使用框架7製作了一個網站。我在另一個頁面中激活一個javascripts時遇到了麻煩。 我的JavaScript是:框架7如何在其他頁面添加javascripts?

function myFunction() { 
var x = document.getElementById('myDIV'); 
if (x.style.display === 'none') { 
    x.style.display = 'block'; 
} else { 
    x.style.display = 'none'; 
}} 

的Javascript在網頁上工作,但是當我加載另一個頁面,它不工作。我知道它必須安裝在my-app.js中,但我不知道如何安裝。

回答

0

基礎上documentation,在這裏我有:

如果你有名字other-page的頁面。頁面名稱會發現:

`<div class="pages"> 
    <div class="page" data-page="other-page"> 
     <div class="page-content"> 
     <!-- ... page content goes here ... --> 
     </div> 
    </div> 
    </div>` 

的話,你可以執行網頁裏面回調函數您:

// In page callbacks: 
myApp.onPageInit('other-page', function (page) { 
    // "page" variable contains all required information about loaded and initialized page 
    // write your function here 
}); 

而且在它之前,請確保您有初始化您的應用程序。

var myApp = new Framework7({ 
    pushState: true, 
    swipePanel: 'left', 
    // ... other parameters 
}); 
相關問題