mikha
asked on
anchor tag in a web application
this is out of curosity. in an html page within in the application, if there is an anchor tag as such
<a href="1234" target="_blank">
if in the href there is an id value, when clicked what is the path it tries to resolve to ?
<a href="1234" target="_blank">
if in the href there is an id value, when clicked what is the path it tries to resolve to ?
ASKER
@ryan- thanks so if there were and just the Id field like you
have , would it route to the same page you are in with this Id value?
have , would it route to the same page you are in with this Id value?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@ryan - thanks. this is something I noticed recently and never really thought of it before. I was working on a express node app, and accidently in the href for anchor tag just put string values. when clicked it goes to http://localhost:3000/stringvalue , wasn't sure if this was something browser was doing or the server, that whenever it sees a value in the href, it appends that to the current path/page you are on.
so do you have a "default page" that user can access to? And what's the reason you want to pass in the "string value" ? Do you wish to pass it as a "parameter" or as a path in URL?
ASKER
I did that by mistake and found out that if I just put a id value , then the page resolves. so say I'm on a page with url below. and in the same page I have anchor tags with href , as such <a href="2" ....> when I click on the this anchor tag , it takes me to localhost:3000/id/2
localhost:3000/id/1
I don't have a default page, but I am looking to see how can I build links in this page to other resources. I was going to put the relative path in the href tag, but just putting the id seems enough. I 'm not sure if this is default behaviour in web app, or certain web app /browser.
localhost:3000/id/1
I don't have a default page, but I am looking to see how can I build links in this page to other resources. I was going to put the relative path in the href tag, but just putting the id seems enough. I 'm not sure if this is default behaviour in web app, or certain web app /browser.
I 'm not sure if this is default behaviour in web app, or certain web app /browser.
I'm also new in Node.js but it seems to me that there are some routes settings in your sample scripts
ASKER
thats good to know. I'm new to node.js too. so is it something we can set it up in routes then. say if we work with .net or ruby on rails where we can define routes ?
I guess as a start, you can refer to:
Routing in Node.js
https://www.geeksforgeeks.org/routing-in-node-js/
the article shows you 2 ways to do that:
Routing in Node.js
https://www.geeksforgeeks.org/routing-in-node-js/
the article shows you 2 ways to do that:
- By Using Framework
- Without using Framework
what inside the href is the URL that will be surfing to.
if you got a link like below:
Open in new window
it will be going to : /?id=1234
it's up to us to define the URL and how it should work.