This description is too short so we can summarize this tutorial in several points:
- obtain the server's IP from the index with javascrip, because its IP is dynamic
- try to modify the text value of a web page at a specific point
- It tries to create the value of a link when the page loads, or of any html tag
- modify the attribute of any html nu tag when loading the page with javascrip
- modify the attribute of an html tag when performing a mouse action before clicking
Dynamically create the index with a link for the daruma cups printserver, create the link using javascrip and changing the tag !a! link!
First, the base code, we create the index.html file with the touch index.html command, the content then we paste it manually and it will be this:
What is the problem? there is the link!
The problem is that this machine has a dynamic IP, and the IPESTATIC part, which would be the IP, would change when the machine was turned off!
The next time I turn on that IP it will not have the same one (here set as IPESTATIC), and for that we are going to obtain it dynamically and write it dynamically on each restart in that html page, but using javascrip!
part 1 get the ip and direct link
This is easy, there is a direct javascrip code, and it is location.host. NOTE: We do not want the IP of the client who visits the page, but rather that of the server to generate the html and the dynamic link from the IP that will always change from the server!
So we create a code that provides that part:
You can see the output:
part 2 obtain the tag link that we want to modify
For this, the most reliable method is to use the "id" attribute since the element object needs to be passed by property.
The trick is that once we have obtained the reference (the name of the id) we can modify the "href" attribute and thus insert the new modified link generated automatically with the changed IP!!
The result is that the text is changed from "original text" to "changed text" and more hidden the href attribute will change to "changed attribute" that had "link"
Part 3 use the link in the obtained tag and modify it
Now we join part 1 into a variable, and use that variable in part 2
Basically, in the second code we put the variable from the first code, thus creating the modified tag with the link!
Final code
:
</html>
No hay comentarios.:
Publicar un comentario
no stupid winbuntu users allowed!