Jump to content
Fórum Script Brasil
  • 0

Erro Ao Mover :javascript


web diackne
 Share

Question

o problema é a juntar a String "icon" ao id enviado '1' que quero como resultado a string junta "icon1"

se alterar

document.getElementById("icon"+id).style.left=tempx+event.clientX-offsetx+"px"

por

document.getElementById("icon1").style.left=tempx+event.clientX-offsetx+"px"

ele funciona

Só dá erro quando tento mover o X

erro: objecto necessário

<div id="icon1" style="position: absolute; width: 105px; height: 68px; z-index: 4; left: 16px; top: 60px; visibility: visible" >

<p align="center"><a href="#" onMousedown="initializedrag2(event,'1')" onMouseup="stopdrag2('1')" onSelectStart="return false"> x</a></div>

<script language=JavaScript type=text/javascript src="...."></script>

<!--

var aprovado=false

var restMini=0

var widthInicial,heightInicial

var ie5=document.all&&document.getElementById

var ns6=document.getElementById&&!document.all

function iecompattest(){

return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body

}

function drag_drop2(e,id){

if (ie5&&aprovado&&event.button==1){

document.getElementById("icon"+id).style.left=tempx+event.clientX-offsetx+"px"

document.getElementById("icon"+id).style.top=tempy+event.clientY-offsety+"px"

}

else if (ns6&&aprovado){

document.getElementById("icon"+id).style.left=tempx+e.clientX-offsetx+"px"

document.getElementById("icon"+id).style.top=tempy+e.clientY-offsety+"px"

}

}

function initializedrag2(e,id){

offsetx=ie5? event.clientX : e.clientX

offsety=ie5? event.clientY : e.clientY

tempx=parseInt(document.getElementById("icon"+id).style.left)

tempy=parseInt(document.getElementById("icon"+id).style.top)

aprovado=true

document.getElementById("icon"+id).onmousemove=drag_drop2

}

function stopdrag2(id){

aprovado=false;

document.getElementById("icon"+id).onmousemove=null;

document.getElementById("icon"+id).style.display="" //extra

}

//-->

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

o problema é a juntar a String "icon" ao id enviado '1' que quero como resultado a string junta "icon1"

se alterar

document.getElementById("icon"+id).style.left=tempx+event.clientX-offsetx+"px"

por

document.getElementById("icon1").style.left=tempx+event.clientX-offsetx+"px"

ele funciona

Só dá erro quando tento mover o X

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Forum Statistics

    • Total Topics
      151k
    • Total Posts
      649.1k
×
×
  • Create New...