I am trying to call a function to open a lightbox when someone clicks a link that create. I have seen this done before but do not recall how something like:
google.com:javascript(openWindow())
does anyone know how I can do this?
I am trying to call a function to open a lightbox when someone clicks a link that create. I have seen this done before but do not recall how something like:
google.com:javascript(openWindow())
does anyone know how I can do this?
javascript:openWindow()
is a URL that most browsers interpret as invoking the openWindow() function and treating the result coerced to a string as the result of loading the URL.
See HTML5 6.1.5 The javascript: URL scheme for more detail.
javascript:window.open('http://www.google.com/');encodeURIComponent(), send it in the querystring, and then eval() it on the target page if the querystring parameter is detected. This does feel quite hacky though, and I don't recommend the approach. It would be better to just pass a querystring parameter to cause a function on the target page to run, possibly using the querystring parameter as an argument.you might be referring to this
<html>
<body>
<script type="text/javascript">
function clickMe(){
//your code here to call lightbox and etc.
alert('test');
}
</script>
<a href="javascript:clickMe()">click</a>
</body>
</html>
Do you mean
<a href="#" onclick="yourOpenLightboxFunction(); return false;" />
This answer gives more detail.
I think it can be BookMark, you can bookmark to quickly run JavaScript functions from your address bar.
The following code ended up being what helped me to complete the task. I found the answer here
var url = document.location.href;
if(url.search(/\?lightbox/i) !== -1){
//run function here
}