Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

嵌入html代碼無法觸發事件 #30

Open
lzh2233 opened this issue Jan 26, 2023 · 5 comments
Open

嵌入html代碼無法觸發事件 #30

lzh2233 opened this issue Jan 26, 2023 · 5 comments

Comments

@lzh2233
Copy link

lzh2233 commented Jan 26, 2023

劇本裏嵌入html時,像自定義的button的onclick事件不能觸發是怎麼回事,有解決辦法嗎,謝謝

@RimoChan
Copy link
Owner

壞了,我2年沒看Librian了,居然有issue,你貼下你的代碼看看?

@lzh2233
Copy link
Author

lzh2233 commented Jan 26, 2023

    <button id = "mybtn">button</button>
    <script>
        let btn = document.getElementById("mybtn");
        btn.onclick = function(){
            alert("responsive");
        }
    </script>

像這樣,畫面點擊沒響應

@RimoChan
Copy link
Owner

RimoChan commented Jan 26, 2023

看起來這應該是一個正常的行爲,在運行時插入的script是不會執行的。也許你可以試試先在js裏定義f,然後<button onclick="f()">

@lzh2233
Copy link
Author

lzh2233 commented Jan 26, 2023

這js是指的是劇本嵌入代碼的js嗎,我試了還是一樣

@RimoChan
Copy link
Owner

我也試了一下,看起來是onclick事件被什麼擋住了,你可以用onmousedown代替一下它……

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants