未捕获的ReferenceError: url没有定义

时间:2021-08-09 19:24:34

So I created a an iphone out of pure css and I am trying to make the screen change on click to make it interactive. I am new to java script, just started learning about it a week or so ago, and browser is telling me "Uncaught ReferenceError: url is not defined" not sure what i'm doing wrong. Any advice on why it is telling me this, so I make sure not to make the same mistake in the future. I am sure it is a simple fix just not sure how to go about it.

所以我用纯css创建了一个iphone我试着在点击时改变屏幕,使它具有交互性。我刚接触java脚本,大约一周前才开始学习它,浏览器告诉我“未捕获的ReferenceError: url没有定义”,不知道我做错了什么。任何关于它为什么告诉我的建议,所以我保证以后不要再犯同样的错误。我确信这是一个简单的解决办法,只是不知道该怎么做。

<div id="iphone-border">
            <div id="off-button"></div>
            <div id="mute-button"></div>
            <div id="volume-up-button"></div>
            <div id="volume-down-button"></div>
            <div id="side-lines-1"></div>
            <div id="side-lines-2"></div>
            <div id="iphone-color">
                <div id="camara"></div>
                <div id="sensor"></div>
                <div id="speaker"></div>
                <div id="iphone-screen" onClick="this.style.backgroundImage=url(img/phone-screen.jpg);" >

                </div>
                <div id="home-button-border">
                    <div id="home-button-color"></div>
                </div>

            </div>
        </div>

1 个解决方案

#1


4  

You're missing the quotes:

你错过了报价:

this.style.backgroundImage = 'url(img/phone-screen.jpg)';

#1


4  

You're missing the quotes:

你错过了报价:

this.style.backgroundImage = 'url(img/phone-screen.jpg)';