0

Hello i want to code an scirpt that downloads / opens an link thats in an class as an href (you can see it on the picture i sent)

i dont know how to do it because im not an experienced coder

i already tried this to pieces of code but without success

document.getElementsByClassName("mycode_color")[0].click(`href`);

document.getElementByClassName('exito_thx message').src = url;

i want that the scirpt opens this href in an new tab

enter image description here

does someone know if its possible and how its done?

or does someone know is its possible to code it to open every link that has "attachement.php" in it?

edit: it's much complicated than i thought it would be

enter image description here

every link is in his own name & id

1 Answers1

0

The a element given in the image doesn't include a class name. Hence you can't target it with a class name. Try this...

window.open(document.querySelector('a').href);

It opens the first encountered anchor element in the webpage.

  • 1
    The first one worked but i think its getting much conplicated i only realised not that every "post" has his own id and class (https://imgur.com/a/9TJlrjE) – Thomas Baum Jul 12 '21 at 09:36