我有我的2個js文件和兩個HTML文件main.html中和log.html只有一個按鈕重定向到main.html中並拋出一個警告更新全局變量
JS文件1個問題: 我有一個全局變量
context= {};
和主:
function main() { if (typeof context.active != 'undefined') alert(context.active); }
JS文件2:
我有一個函數
function setActive() { context.active=true; window.location.href="main.html"; }
當我點擊我的按鈕,它重定向我main.html中卻沒有什麼反應(所以它是不確定的)。我做了幾個測試,按鈕的作品。爲什麼它不更新context.active?
謝謝。
'setActive {}'應該做什麼? – adeneo
你在HTML中包含JS文件1嗎? –
做兩個js文件包含在html文件中(以正確的順序)? – vlio20