Javascript,這一行是什麼意思?"函數 myslide() { document.images.slideshow.src=eval("image"+numberImage+".src)"? (Javascript, what does this line mean? "function myslide() { document.images.slideshow.src=eval("image"+numberImage+".src)"?)


問題描述

Javascript,這一行是什麼意思?"函數 myslide() { document.images.slideshow.src=eval("image"+numberImage+".src)"? (Javascript, what does this line mean? "function myslide() { document.images.slideshow.src=eval("image"+numberImage+".src)"?)

最近有人要求我做一個網站,但我不熟悉 Javascript,“document.images.slideshow.src”是否被視為路徑?如果我要將它複製到另一台計算機怎麼辦?它還會起作用嗎?我擔心它會創建不同的路徑


參考解法

方法 1:

documet.imgaes is a collection containing all the images on a page. slideshow is one of the images in the collection (there's img id="slideshow" on the page). src is the ... well, src of that image.

eval() creates a path from a variable containing a reference to img id="image0" (0 is just an example, might be something else too).

Basicly the code just copies src of an existing image, and shows that same image in another img element. The used computer doesn't matter, if you're creating a webpage, as you've told us.

(by Erich TamioTeemu)

參考文件

  1. Javascript, what does this line mean? "function myslide() { document.images.slideshow.src=eval("image"+numberImage+".src)"? (CC BY‑SA 2.5/3.0/4.0)

#javascript






相關問題

為什麼我不能在 IE8 (javascript) 上擴展 localStorage? (Why can't I extend localStorage on IE8 (javascript)?)

在 Javascript 中打開外部 sqlite3 數據庫 (Open external sqlite3 database in Javascript)

Javascript:數組中的所有對像都具有相同的屬性 (Javascript: All Objects in Array Have Same Properties)

為什麼我們要在 javascripts 原型中添加函數? (Why do we add functions to javascripts prototype?)

顯示 URL javascript 的最後一部分? (Display the last part of URL javascript?)

Javascript XMLHttpRequest:忽略無效的 SSL 證書 (Javascript XMLHttpRequest: Ignore invalid SSL Certificate)

有沒有辦法測試 console.log 整體 (Is there a way to test for console.log entires)

如何從 javascript 對像中獲取名稱和值到新列表中? (How to get name and values from a javascript object into a new list?)

數據未發布..幫助!html,js,firebase (Data not posting.. Help! html,js,firebase)

使用 Node.js 腳本查看表單數據 (Seeing form data with Node.js script)

使用百分比查找範圍內的值 (find the value within a range using percent)

如何通過 react.js 中的組件傳遞變量或數據? (How to pass varible or data through components in react.js?)







留言討論