Difference between revisions of "Widget:UrlButton"
m (try and see if the button doesn't trigger a request) |
m (...) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 31: | Line 31: | ||
window.buttonRequest = function( _event ) | window.buttonRequest = function( _event ) | ||
{ | { | ||
− | + | if ( !_event ) | |
+ | _event = window.event; | ||
+ | var img = document.createElement( "img" ); | ||
+ | img.src = _event.target.href; | ||
+ | img.style.visibility = "hidden"; | ||
+ | document.body.appendChild( img ); | ||
+ | setTimeout( function() | ||
+ | { | ||
+ | document.body.removeChild( img ); | ||
+ | }, 200 ); | ||
_event.preventDefault(); | _event.preventDefault(); | ||
} | } | ||
} | } | ||
− | document.write( '<a href="<!--{$url|validate:url}-->" onclick=" | + | document.write( '<a href="<!--{$url|validate:url}-->" onclick="buttonRequest()"><!--{$text|escape:html|default:auto}--></a>' ); |
}( )); | }( )); | ||
</script> | </script> | ||
</includeonly> | </includeonly> |
Latest revision as of 08:11, 13 April 2018
This widget allows you to create a (http) link that gets called on the background. This can be used to switch a light, pan a camera or skip a song.
Created by Xopr
Using this widget
To insert this widget, use the following code:
{{#widget:UrlButton |text=Left |url=http://camera?Direction=PanLeft }}
This will give the following result:
Note that url and text is mandatory.
Copy to your site
To use this widget on your site, just install MediaWiki Widgets extension and copy full source code of this page to your wiki as Widget:UrlButton article.