Ir para conteúdo
Fórum Script Brasil

David's Eclipse

Membros
  • Total de itens

    4
  • Registro em

  • Última visita

Sobre David's Eclipse

David's Eclipse's Achievements

0

Reputação

  1. Sim, Jonathan. Para que a linguagem XML aceite o javascript, é necessário várias adaptações. Sendo que ao final, após as adaptações, o código deixa de funcionar. Então eu gostaria de formatar o código abaixo em um documento .JS. <head> <style> <!-- /* Context menu Script- © Dynamic Drive (www.dynamicdrive.com) Last updated: 01/08/22 For full source code and Terms Of Use, visit http://www.dynamicdrive.com */ .skin0{ position:absolute; width:165px; border:2px solid black; background-color:menu; font-family:Verdana; line-height:20px; cursor:default; font-size:14px; z-index:100; visibility:hidden; } .menuitems{ padding-left:10px; padding-right:10px; } --> </style> </head> <body> <div id="ie5menu" class="skin0" onMouseover="highlightie5(event)" onMouseout="lowlightie5(event)" onClick="jumptoie5(event)" display:none> <div class="menuitems" url="http://dynamicdrive.com">Dynamicdrive.com</div> <div class="menuitems" url="http://dynamicdrive.com/new.htm" target="newwin">What's New?</div> <div class="menuitems" url="http://dynamicdrive.com/hot.htm">What's Hot?</div> <div class="menuitems" url="http://wsabstract.com/cgi-bin/Ultimate.cgi">Message Forum</div> <div class="menuitems" url="http://dynamicdrive.com/faqs.htm">FAQs</div> <div class="menuitems" url="http://dynamicdrive.com/submitscript.htm">Submit</div> <hr> <div class="menuitems" url="mailto:dynamicdrive@yahoo.com">Email Us</div> </div> &lt;script language="JavaScript1.2"> //set this variable to 1 if you wish the URLs of the highlighted menu to be displayed in the status bar var display_url=0 var ie5=document.all&&document.getElementById var ns6=document.getElementById&&!document.all if (ie5||ns6) var menuobj=document.getElementById("ie5menu") function showmenuie5(e){ //Find out how close the mouse is to the corner of the window var rightedge=ie5? document.body.clientWidth-event.clientX : window.innerWidth-e.clientX var bottomedge=ie5? document.body.clientHeight-event.clientY : window.innerHeight-e.clientY //if the horizontal distance isn't enough to accomodate the width of the context menu if (rightedge<menuobj.offsetWidth) //move the horizontal position of the menu to the left by it's width menuobj.style.left=ie5? document.body.scrollLeft+event.clientX-menuobj.offsetWidth : window.pageXOffset+e.clientX-menuobj.offsetWidth else //position the horizontal position of the menu where the mouse was clicked menuobj.style.left=ie5? document.body.scrollLeft+event.clientX : window.pageXOffset+e.clientX //same concept with the vertical position if (bottomedge<menuobj.offsetHeight) menuobj.style.top=ie5? document.body.scrollTop+event.clientY-menuobj.offsetHeight : window.pageYOffset+e.clientY-menuobj.offsetHeight else menuobj.style.top=ie5? document.body.scrollTop+event.clientY : window.pageYOffset+e.clientY menuobj.style.visibility="visible" return false } function hidemenuie5(e){ menuobj.style.visibility="hidden" } function highlightie5(e){ var firingobj=ie5? event.srcElement : e.target if (firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){ if (ns6&&firingobj.parentNode.className=="menuitems") firingobj=firingobj.parentNode //up one node firingobj.style.backgroundColor="highlight" firingobj.style.color="white" if (display_url==1) window.status=event.srcElement.url } } function lowlightie5(e){ var firingobj=ie5? event.srcElement : e.target if (firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){ if (ns6&&firingobj.parentNode.className=="menuitems") firingobj=firingobj.parentNode //up one node firingobj.style.backgroundColor="" firingobj.style.color="black" window.status='' } } function jumptoie5(e){ var firingobj=ie5? event.srcElement : e.target if (firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){ if (ns6&&firingobj.parentNode.className=="menuitems") firingobj=firingobj.parentNode if (firingobj.getAttribute("target")) window.open(firingobj.getAttribute("url"),firingobj.getAttribute("target")) else window.location=firingobj.getAttribute("url") } } if (ie5||ns6){ menuobj.style.display='' document.oncontextmenu=showmenuie5 document.onclick=hidemenuie5 } </script> </body> Corrija-me se eu estiver errado, mas penso que seria possível formatar o javascript do código acima em um documento .JS para ser chamado pela página através de SRC="...contextmeu.js", sem haver a necessidade de alterar o restante do código. Desde já agradeço a sua ajuda!
  2. Olá, Jonathan! Obrigado por responder! Encontrei o que preciso neste site: http://www.dynamicdrive.com/dynamicindex1/contextmenu.htm Mas estou com um problema: Preciso inserir este código em uma página com linguagem XML. Sendo assim, a linguagem do código é incompatível. Há alguma forma de formatar o código em um documento .JS (contextmenu.js, por exemplo) para que eu possa posta-lo no Google Code (ou semelhante) e então chama-lo através de <script type="text/javascript" src=".../contextmenu.js">?
  3. Alguém poderia me ajudar na elaboração de um menu de contexto (aquele ativado com o botão direito do mouse) válido para o Internet Explorer, Fire Fox, Google Chrome, Opera e Safari? Encontrei alguns aqui no fórum, mas não funcionaram por dois motivos: 1º. Só "funcionavam" no IE; 2º. Mesmo no IE, apresentava um problema: Quando a página era rolada, o menu não acompanhava. Isto é, ao clicar com o botão direito do mouse o menu era chamado (normalmente), mas ao rolar a página e clicar novamente com o botão direito, o menu continuava a ser exibido no topo da página. Por favor, agradeço se puderem me ajudar.
  4. Bom dia a todos! Espero estar postando no local correto; caso contrário me desculpem. Estou tentando introduzir um menu para o botão direito do mouse em um blog (blogspot). Sendo que o template (modelo) está formatado em XML. Mas o script não está funcionando corretamente. Segue abaixo o código: <script language='JavaScript1.2'> var display_url=0 function showmenuie5(){ var rightedge=document.body.clientWidth-event.clientX var bottomedge=document.body.clientHeight-event.clientY if (rightedge<ie5menu.offsetWidth) ie5menu.style.left=document.body.scrollLeft+event.clientX-ie5menu.offsetWidth else ie5menu.style.left=document.body.scrollLeft+event.clientX if (bottomedge<ie5menu.offsetHeight) ie5menu.style.top=document.body.scrollTop+event.clientY-ie5menu.offsetHeight else ie5menu.style.top=document.body.scrollTop+event.clientY ie5menu.style.visibility="visible" return false } function hidemenuie5(){ ie5menu.style.visibility="hidden" } function highlightie5(){ if (event.srcElement.className=="menuitems"){ event.srcElement.style.backgroundColor="" event.srcElement.style.color="white" event.srcElement.style.backgroundColor="royalblue" if (display_url==1) window.status=event.srcElement.url } } function lowlightie5(){ if (event.srcElement.className=="menuitems"){ event.srcElement.style.backgroundColor="" event.srcElement.style.color="black" window.status='' } } function jumptoie5(){ if (event.srcElement.className=="menuitems") window.location=event.srcElement.url } </SCRIPT> O Blogger retorna ao seguinte erro: Não foi possível analisar o seu modelo, pois sua formatação é inadequada. Certifique-se de que todos os elementos XML estão fechados adequadamente. Mensagem de erro em XML: Element type "ie5menu.offsetWidth" must be followed by either attribute specifications, ">" or "/>". Ou seja, sugere "if (rightedge<ie5menu.offsetWidth />) e (bottomedge<ie5menu.offsetHeight />), respectivamente. Entretanto, isto (obviamente) faz com que o código deixe de funcionar. Por favor, preciso de ajuda! Segundo problema. Segue o código: <script language='JavaScript1.2'> document.oncontextmenu=showmenuie5 if (document.all&window.print) document.body.onclick=hidemenuie5 </script> <script> function abremenu(x){ if (IE) { document.all.divinfos[x-1].style.visibility="hidden"; document.all.divinfos[x-1].style.display=''; document.all.divinfos[x-1].style.filter="blendTrans(duration=.5)"; document.all.divinfos[x-1].filters.blendTrans.Apply(); document.all.divinfos[x-1].style.visibility="visible"; document.all.divinfos[x-1].filters.blendTrans.Play(); } } function fechamenu(x){ if (IE) { document.all.divinfos[x-1].style.visibility="hidden"; document.all.divinfos[x-1].style.display='none'; } } </script> O Blogger retornou ao seguinte erro: Não foi possível analisar o seu modelo, pois sua formatação é inadequada. Certifique-se de que todos os elementos XML estão fechados adequadamente. Mensagem de erro em XML: The reference to entity "window.print" must end with the ';' delimiter. Isto é, pede para que eu feche a sintaxe "windows.print" com ";". Fiz algumas alterações: Quanto ao primeiro problema, substitui "rightedge<ie5menu.offsetWidth" e "bottomedge<ie5menu.offsetHeight" por "rightedge& #00060;ie5menu.offsetWidth" e "bottomedge& #00060;ie5menu.offsetHeight" (sem espaços entre & #), respectivamente. Quanto ao segundo problema, substituí "&" por "& amp;" (sem espaço entre & e amp;). O Blogger aceitou e salvou o documento. Mas o script não está funcionando corretamente. Isto é, não funciona no Google Chrome e no Internet Explorer funciona somente na metade superior da página. Pesquisei em vários sites e fóruns; e não há nada semelhante. O único lugar onde notei que entendem do assum é aqui. Há, inclusive, um tópico em que um dos moderadores elaborou um código semelhante, porém bastante simplificado e com funções de copiar e colar. Por favor, preciso de ajuda!
×
×
  • Criar Novo...