Home > Web Front-end > JS Tutorial > Nice way to use external Javascript to modify specific web page content_javascript tips

Nice way to use external Javascript to modify specific web page content_javascript tips

WBOY
Release: 2016-05-16 19:09:33
Original
1032 people have browsed it

This code is written by me to help others solve a problem.
The requirements are as follows:

test, this cannot be changed, you can only do things outside, So what?

Requires clicking on the link above to open a new page and perform other operations on the original page.

Analysis shows that the way to open a new page above is wrong, and it is impossible to open a new page at all. The correct way to write it should be:


test


So the solution is to use external js to modify the content of the connection. First, determine that the href attribute inside the link contains "window.open", then add the onclick attribute to it and assign the href content to it. Then modify the href attribute content.
However, a problem was discovered during the solution process. When reading the href attribute content, the actual content cannot be obtained, but the url path of the web page (removing the last page file name) + href content, and the previous url path must be removed. This can be solved using substring() combined with indexOf().
As for the content on the original page, it is much simpler.
Based on the analysis, I wrote the following test code to achieve the above requirements:


[Ctrl A select all Note: If you need to introduce external Js, you need to refresh to execute
]
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template