I'm trying to write something that will go to the URL that this function creates.
<script type="text/javascript">
function VLink() {
var callNumHeading = $("th[class='BItemsHeader']:contains(NO.)");
Num = $('table[id="B_items"] tbody tr td a').eq($(NumHeading).index()).text();
var link = "http://someURL/?q="+Num;
return link;
}
$(document).ready(function() {
var link = VLink();
});
</script>
I need to create code that will go to the link created in the function above. The closest I've come is this:
<a href="javascript:VLink(); ">My Link</a>
This code goes to a page that says it has the same URL as the original page, but all that appears on the page is the URL that I want to go to. The desired destination URL is appearing in the body of the page instead of the address bar.
window.location = VLink();
这应该重定向VLink()创建的页面。
This will redirect:
window.location.href = VLink();
As VLink returns a string, setting to window.location.href
seems most fitting.
window.location is an object which as many other methods.
Regards,
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.