Creating a function for highslide

Asked

Viewed 25 times

0

I’m using the highslide to open the internal pages.

What sucks is that he has the command onclick very large:

<a class="btn btn-success" href="comercialContatoAdicionar.php?i=2a" onclick="return hs.htmlExpand(this, {objectType: 'iframe', width: 900, height: 700, preserveContent: false } )">Adicionar novo contato</a>

It is possible to transform this command of the onclick in a function or something that makes the link smaller.

Thank you.

  • Are multiple links on the page or one?

  • There are several, so I’m trying to change, there are hours I need to move the horizontal scroll to see the code.

  • Hugocss' answer must then solve.

1 answer

2


It is possible yes you can make one forEach() and perform the function for each individually clicked btn...

let meulink = document.querySelectorAll('.btn-success');

function frame(el){
  console.log(el.target);
  // return hs.htmlExpand(this, {objectType: 'iframe', width: 900, height: 700, preserveContent: false } );
}

meulink.forEach(element => {
  element.addEventListener('click', frame)
});
<a class="btn btn-success" href="#" >contato 111</a>
<a class="btn btn-success" href="#" >contato 222</a>

  • Instead of el.target you can just use this.

  • @Sam was worth the touch, this is still kind of confusing for me yet rss

Browser other questions tagged

You are not signed in. Login or sign up in order to post.