Use window.open():
<a onclick="window.open(document.URL, '_blank', 'location=yes,height=570,width=520,scrollbars=yes,status=yes');">
Share Page
</a>
This will create a link titled Share Page which opens the current url in a new window with a height of 570 and width of 520.
Videos
Use window.open():
<a onclick="window.open(document.URL, '_blank', 'location=yes,height=570,width=520,scrollbars=yes,status=yes');">
Share Page
</a>
This will create a link titled Share Page which opens the current url in a new window with a height of 570 and width of 520.
Just use window.open() function? The third parameter lets you specify window size.
Example
var strWindowFeatures = "location=yes,height=570,width=520,scrollbars=yes,status=yes";
var URL = "https://www.linkedin.com/cws/share?mini=true&url=" + location.href;
var win = window.open(URL, "_blank", strWindowFeatures);
To avoid circular calls, you need to stash away the original window.open function in a variable.
A nice way (that doesn't pollute the global namespace) is to use a closure. Pass the original window.open function to an anonymous function as an argument (called open below). This anonymous function is a factory for your hook function. Your hook function is permanently bound to the original window.open function via the open argument:
window.open = function (open) {
return function (url, name, features) {
// set name if missing here
name = name || "default_window_name";
return open.call(window, url, name, features);
};
}(window.open);
I know this reply is a little late, but I felt that a more general solution may be helpful for other people (trying to override other methods)
function wrap(object, method, wrapper){
var fn = object[method];
return object[method] = function(){
return wrapper.apply(this, [fn.bind(this)].concat(
Array.prototype.slice.call(arguments)));
};
};
//You may want to 'unwrap' the method later
//(setting the method back to the original)
function unwrap(object, method, orginalFn){
object[method] = orginalFn;
};
//Any globally scoped function is considered a 'method' of the window object
//(If you are in the browser)
wrap(window, "open", function(orginalFn){
var originalParams = Array.prototype.slice.call(arguments, 1);
console.log('open is being overridden');
//Perform some logic
//Call the original window.open with the original params
orginalFn.apply(undefined, originalParams);
});