我需要将src
中的图像background.coffee
设置为另一页,但是当我从backround.coffee
调用该函数时,会得到view.setScreenshotUrl is not a function
。
//background.coffee
views = chrome.extension.getViews()
for view in views
if view.location.href is viewTabUrl
view.setScreenshotUrl screenshotUrl
break
//page.coffee
setScreenshotUrl = (url) ->
document.getElementById("target").src = url
答案 0 :(得分:1)
我将函数添加到窗口对象中,如下所示:
window.setScreenshotUrl = (url) ->
document.getElementById("target").src = url