我需要将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
我将该函数添加到窗口对象中:
window.setScreenshotUrl = (url) ->
document.getElementById("target").src = url