Home › Forums › JavaScript › Button Link to another page through JavaScript
- This topic is empty.
-
AuthorPosts
-
April 24, 2014 at 5:50 pm #168632
cyclingg
ParticipantI know you can link to another page through HTML.
I am creating a table using JavaScript. I am using arrays to place all the rows and cells.
In one of my cells for each row, I created a button (in my javaScript array). I would like to go to an id name on another page when you click this button. I cannot seem to add a link to the button. I can do this when using HTML and CSS; but, not with javaScript. I can also get this working when I just link my text from the table to my page (using javaScript). I do not want to know how with jQuery or Ajax or php; I am trying to learn javaScript at the moment.
Is this possible?
Here is an example of what I am trying to do:
I only added the button input for one of the elements.//initialize and set up the 'bookButtons' array var bookButtons = new Array(); bookButtons[0] = "<input type='button' id='htmlcss' value='Shop Similar'>"; bookButtons[1] = "JavaScript"; bookButtons[2] = "Photoshop"; bookButtons[3] = "Painter"; bookButtons[4] = "Digital Painting";
I tried adding an onclick statement at the end after ‘shop similar’ with a link to my other page. It did not work. Am I totally out to lunch?
Thanks.
April 24, 2014 at 9:01 pm #168641cyclingg
ParticipantHi TheDoc
I want a button.
I found a way I might be able to do this. It is with onClick = “document.location = ‘somefile.htm#someId’ “.
I have not used “document.location yet. I will try it later tonight.
April 25, 2014 at 2:18 am #168654Paulie_D
Member…or just use a
<button>
April 25, 2014 at 7:54 pm #168716cyclingg
ParticipantI decided to just use my images as links. The button idea did not work.
I did not want to use an image of a button; that is not the point of this exercise. I know how to use images as links.
I am taking a JavaScript course and our assignment was on Arrays. I made a table using JavaScript and wanted a button to be used as a link. It did not work; I made the button but it would not link out. It is not a requirement for this assignment; so, I am using my images as links.
Thanks.
-
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.