Any smart way of doing a "root" based path referencing in JavaScript, just the way we have ~/
in ASP.NET?
The in operator returns true if the specified property is in the specified object or its prototype chain.
Python's pass mainly exists because in Python whitespace matters within a block. In Javascript, the equivalent would be putting nothing within the block, i.e. {} . Show activity on this post. This is equivalent to leaving the block with nothing in it, but is good for readability reasons.
Have your page generate a tag with something like:
<link rel="home" id="ApplicationRoot" href="http://www.example.com/appRoot/" />
Then, have a function in JavaScript that extracts the value such as:
function getHome(){ return document.getElementById("ApplicationRoot").href; }
Use base tag:
<head> <base href="http://www.example.com/myapp/" /> </head>
...
from now any link use on this page, no matter in javascript or html, will be relative to the base tag, which is "http://www.example.com/myapp/".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With