[英]Find a named link on the page, then go click it - in Javascript
I'm using Greasekit, so needs this to be in Javascript, please 我正在使用Greasekit,因此需要使用Javascript
Click the link called < Previous
so that it opens in a new window (in the example below, it goes to Page 22, but it could be any number, so it really needs to look for this specific link) 单击名为
< Previous
的链接,以便在新窗口中打开(在下面的示例中,它转到第22页,但是它可以是任何数字,因此它确实需要查找此特定链接)
<table class="v_page_nav" border="0" cellpadding="5" cellspacing="0" width="100%">
<tr>
<td width="100%">Showing 551-575 of 610 Results</td>
<td>
<a href="/wine/newsletter?ie=UTF8&page=22" id="pagination-prev-link">
< Previous</a>| Page:</td>
<td class="off">
<a href="/gp/vine/newsletter?ie=UTF8&page=1" id="pagination-page-1">1</a>
</td>
<td>...</td>
<td class="off">
<a href="/wine/newsletter?ie=UTF8&page=22" id="pagination-page-22">22</a>
</td>
<td class="on">
<a href="/wine/newsletter?ie=UTF8&page=23" id="pagination-page-23">23</a>
</td>
<td class="off">
<a href="/wine/newsletter?ie=UTF8&page=24" id="pagination-page-24">24</a>
</td>
<td class="off">
<a href="/wine/newsletter?ie=UTF8&page=25" id="pagination-page-25">25</a>
</td>
<td>| <a href="/wine/newsletter?ie=UTF8&page=24" id="pagination-next-link">Next ></a>
</td>
</tr>
</table>
the last two lines of the answer are probably: 答案的最后两行可能是:
link.target="_blank";
link.click();
(this is to open the link in the new window) ..but what I want to know is how to write the rest of the code; (这是在新窗口中打开链接)..但是我想知道的是如何编写其余代码; the lines that go above it.
上方的线。
an alternative to finding < Previous
might be to look for a link with the id pagination-prev-link
查找
< Previous
一个的替代方法可能是查找带有id pagination-prev-link
考虑您的最后一句话:
var link = document.getElementById('pagination-prev-link');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.