Reputation: 33
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.
Upvotes: 3
Views: 123
Reputation: 2251
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,
Upvotes: 0
Reputation: 326
window.location = VLink();
That should redirect the page that is created by VLink().
Upvotes: 2