如何使用 JavaScript 更改 HTML 链接值?

发布于 2024-09-15 06:30:31 字数 1767 浏览 3 评论 0原文

我有一个 HTML 页面,我想在其中更改图像和内容定期链接。 我在 Head 标签中有以下代码:

<sctipt>
var slideimages=new Array()
var slidelinks=new Array()
var text = document.getElementById('slidetext')

function slideshowimages(){
  for (i=0;i<slideshowimages.arguments.length;i++){
  slideimages[i]=new Image()
  slideimages[i].src=slideshowimages.arguments[i]
  text.innerHTML = textChange.aruguments[i]
  }
}

function slideshowlinks(){
  for (i=0;i<slideshowlinks.arguments.length;i++)
  slidelinks[i]=slideshowlinks.arguments[i]
}

function gotoshow(){
  if (!window.winslide||winslide.closed)
    winslide=window.open(slidelinks[whichlink])
  else
    winslide.location=slidelinks[whichlink]
    winslide.focus()
}
</script>

在 Body 标签中有以下代码:

<script>
slideshowimages("D:/Search/images/back1.jpg", "D:/Search/images/back2.jpg", "D:/Search/images/back3.jpg","D:/Search/images/back4.jpg","D:/Search/images/back5.jpg","D:/Search/images/back7.jpg")
slideshowlinks("http://wsabstract.com", "http://dynamicdrive.com", "http://java-scripts.net","http://stackoverflow.com","http://superuser.com","http://serverfault.com")
textChange("wsaabstract","dynamicdrive","java-script","stackoverflow","superuser","serverfault")


var slideshowspeed=3000
var whichlink=0
var whichimage=0

function slideit(){
  if (!document.images)
    return
    document.images.slide.src=slideimages[whichimage].src
    document.getElementById('slidetext').innerHTML=text.value
    whichlink=whichimage

  if (whichimage<slideimages.length-1)
    whichimage++
  else
    whichimage=0
    setTimeout("slideit()",slideshowspeed)
}
</script>

图像会定期更改,但仅当我没有使用“slidetext”文本标签(也是超链接)时。但是,使用文本标签、图像和标签文字变得稳定。那么,应该如何修改来改变图像和内容呢?定期发送文本。

I have an HTML page where I want to change Image & Link with at regular interval of time.
I have following code in Head Tag :

<sctipt>
var slideimages=new Array()
var slidelinks=new Array()
var text = document.getElementById('slidetext')

function slideshowimages(){
  for (i=0;i<slideshowimages.arguments.length;i++){
  slideimages[i]=new Image()
  slideimages[i].src=slideshowimages.arguments[i]
  text.innerHTML = textChange.aruguments[i]
  }
}

function slideshowlinks(){
  for (i=0;i<slideshowlinks.arguments.length;i++)
  slidelinks[i]=slideshowlinks.arguments[i]
}

function gotoshow(){
  if (!window.winslide||winslide.closed)
    winslide=window.open(slidelinks[whichlink])
  else
    winslide.location=slidelinks[whichlink]
    winslide.focus()
}
</script>

And Following Code in Body Tag :

<script>
slideshowimages("D:/Search/images/back1.jpg", "D:/Search/images/back2.jpg", "D:/Search/images/back3.jpg","D:/Search/images/back4.jpg","D:/Search/images/back5.jpg","D:/Search/images/back7.jpg")
slideshowlinks("http://wsabstract.com", "http://dynamicdrive.com", "http://java-scripts.net","http://stackoverflow.com","http://superuser.com","http://serverfault.com")
textChange("wsaabstract","dynamicdrive","java-script","stackoverflow","superuser","serverfault")


var slideshowspeed=3000
var whichlink=0
var whichimage=0

function slideit(){
  if (!document.images)
    return
    document.images.slide.src=slideimages[whichimage].src
    document.getElementById('slidetext').innerHTML=text.value
    whichlink=whichimage

  if (whichimage<slideimages.length-1)
    whichimage++
  else
    whichimage=0
    setTimeout("slideit()",slideshowspeed)
}
</script>

The Images are changing regularly but only when I have not used the text label that is "slidetext" (which is also hyperlink). But, Using text label, image & text become steady. So, what should be modification to change image & text at regular interval.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

入怼 2024-09-22 06:30:31

text.innerHTML = textChange.aruguments[i]

正常,您的代码中存在错误吗?

text.innerHTML = textChange.aruguments[i]

Normal the fault in your code ?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文