How can I open new browser tabs without focus on them?
(Like clicking on the middle button on a mouse.)
Code:
$("html").on "click", ->
window.open('http://google.com')
$(document).focus()
And I want to still be on the current site.
This answer details what seems to be a legitimate way to open a tab in the background. Converting the answer to CoffeeScript, I get:
openNewBackgroundTab = ->
a = document.createElement("a")
a.href = "http://www.google.com/"
evt = document.createEvent("MouseEvents")
#the tenth parameter of initMouseEvent sets ctrl key
evt.initMouseEvent "click", true, true, window, 0, 0, 0, 0, 0, true, false, false, false, 0, null
a.dispatchEvent evt
return
Related
This is a subject based on "jqGrid - Change filter/search pop up form - to be flat on page - not a dialog" .
I've made the search form to be flat based on the subject , but right now I want not to show always on page , I want to show it only when the user press Search button from the jqGrid.
Can anyone give me an hint or solution how to do that, please?
#Oleg can you help me with that , please?
Thanks
Th solution could be very close to the old one. You can use the following options of the searching dialog:
overlay: 0,
drag: false,
beforeShowSearch: function ($form) {
var $searchDialog = $form.closest(".ui-jqdialog"),
$gbox = $(this).closest(".ui-jqgrid");
$searchDialog.insertBefore($gbox);
$searchDialog.css({
position: "relative",
zIndex: "auto",
float: "left"
})
$gbox.css({clear:"left"});
}
Other options (like closeOnEscape: true, closeAfterSearch: true, closeAfterReset: true, searchOnEnter: true, searchOperators: true and other) can be chosen depend on your preferences.
The demo displays the searching dialog like
If you prefer to use Bootstrap CSS instead of jQuery UI CSS then one should add some additional lines:
overlay: 0,
drag: false,
beforeShowSearch: function ($form) {
var $searchDialog = $form.closest(".ui-jqdialog"),
$gbox = $(this).closest(".ui-jqgrid");
$searchDialog.insertBefore($gbox);
$searchDialog.css({
position: "relative",
zIndex: "auto",
padding: 0,
float: "left"
});
$searchDialog.children(".modal-dialog").css({
marginTop: 0,
marginBottom: 0
});
$searchDialog.find(".modal-content").css({
boxShadow: "none"
});
$gbox.css({clear:"left"});
}
See the demo which displays:
I am building an online map app, using Openlayers, which enables popup information by clicking on features. The info was brought by wms getfeatureinfo.
I wonder if there is a simple way to change the mouse cursor to, say, hand when the mouse hovers over the selectable feature. This is to help users identify that the features are clickable and info can be retrieved.
The attached is my current code. Thanks!
shelter_info = new OpenLayers.Control.WMSGetFeatureInfo ({
url:"****",
title: 'Identify evacuation centres by clicking',
layers:[evacuation_center],
queryVisible: true,
hover: true,
eventListeners:{
getfeatureinfo: function(event){
if (event.text.indexOf("<b>") != -1){ //only display popup when selected the WMS object.
var popup = new OpenLayers.Popup.FramedCloud(
"shelter_popup",
map.getLonLatFromPixel(event.xy),
null,
event.text,
null,
true,
null
);
popup.autoSize = true;
popup.minSize = new OpenLayers.Size(180,180);
//feature.popup = popup;
map.addPopup(popup);
}
}
}
});
I have an HTML5 page with several data inputs inside a jQuery Dialog box. I sweep this data into form processing with the input attribute form=dataInput. It works fine in Firefox and Chrome, but not in IE because IE does not support the input form attribute. Something about the Dialog widget makes input box elements 'invisible' to form processing. The form attribute fixes this for browsers that support HTML5, but no released IE has this support. I tried $('.ui-dialog').appendTo('form'); in the Dialog open: option, but it does not fix the problem. Is there a way to get IE to sweep input data out of a Dialog widget and into $_POST ?
Here is a sample of an input box inside the Dialog
<label><input type="radio" id="unitedStates" name="country" form="dataInput" value="US">United States</label>
I use the jQuery Form plug-in to perform the submit. It has some options, like beforeSubmit and beforeSerialize, but I don't understand the documentation or the submit process well enough to know if they can be used to solve this problem. Please be specific with code or tutorials. I'm new enough to this that I don't follow general instructions well. ;-) (BTW, IE has the other feature support I need, just not this one.)
Here's my code with Andrew Hagner's suggestion and my modification. Dialog works, but IE does not set a value for the country. What needs to change?
var countrySelected = $("input[type=radio][name=country]").val(); //set earlier by W3C geocoding
var countryChooser = $('#countryChoices').dialog( {
autoOpen: false,
bgiframe: true,
height: 300,
width: 850,
resizable: false,
draggable: true,
title: "Click to select another country",
open: function () {
$('#regions').tabs(
{
event: "mouseover",
})
},
buttons: {
'Close / continue location input': function ()
{
countrySelected = $('input[name=country]:checked').val();
$(this).dialog('close');
}
}
});
//then later on
getCityFromGeonames3Step(countrySelected);
Updated:
// Before you enter dialog, assign the element you will
// be grabbing the info from to a variable.
var countrySelectionElement = $("input[type=radio][name=country]").val();
var countrySelected = "";
var countryChooser = $('#countryChoices').dialog( {
autoOpen: false,
bgiframe: true,
height: 300,
width: 850,
resizable: false,
draggable: true,
title: "Click to select another country",
open: function () {
$('#regions').tabs(
{
event: "mouseover",
})
},
buttons: {
'Close / continue location input': function ()
{
// Since jQuery won't work in here, use the variable
// we assigned above to access value.
countrySelected = countrySelectionElement.val();
$(this).dialog('close');
}
}
});
//then later on
getCityFromGeonames3Step(countrySelected);
Original:
Before you open the dialog assign the input to a variable:
function OpenDialog()
{
var input = $("yourinput");
// Open dialog, use input to work with that element.
// If you want you can then place the entered data in a hidden field
// using jQuery, in the same way we are using input here. Then you will
// be able to post that data back however you like.
}
I had this problem the other day, I found this solution on jQuery's Dialog site.
http://jqueryui.com/demos/dialog/#modal-form
I'm trying to use Firebug's command line to force a click event. This is as far as I've got and it's not very far.
document.getElementsByClassName('this_button').click();
Is is it possible to do what I want?
Thank you!
I wonder why no one provided a solution so far.
What you are searching for is this:
function simulateClick(element) {
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window,
0, 0, 0, 0, 0, false, false, false, false, 0, null);
element.dispatchEvent(evt);
}
For more info see document.createEvent.
I didn't try it in other browsers, but at least it work for me in Firefox 18.0.1.
I am using TinyMCE . On a Click I am opening an inline popup successfully.But I have no idea how I can pass a value from popup to tinyMCE.Any help highly appreciated.
tinyMCE.activeEditor.windowManager.open({
file : "options.jsp",
title : 'Image Manager',
width : 800,
height : 600,
resizable : "yes",
inline : "yes",
close_previous : "no",
win : window
});
Took me some time to find it out myself. It is not that difficult. To insert HTML to your editor from the popup you may use something like
var my_html_code = 'New phrase!';
tinyMCEPopup.execCommand('mceInsertContent', false, my_html_code);
Using tinyMCEPopup.editor you may address the editor from where you opened the popup.
You could for example set a variable in the editor using
tinyMCEPopup.editor.new_variable = 'blah blah';