I trying download PDF through Datatable in Safari browser but .trigger() event is not working. It working properly with chrome and mozilla firefox
Here is HTML code
Export as PDF
Java Script
$('#tablePDF').on('click', function(){
for(var i = 0; i < tables.length; i++){
var table;
table = tables[i];
table.button( '0-0' ).trigger();
}
});
where "tables" is array type of varible where i pushed datatable properties.
Kindly provide solution.
Related
I have too many Google Photos assistant's cards accumulated
How would I dismiss all those cards at once using JavaScript?
With JavaScript it's possible to do like this:
var buttons = document.getElementsByClassName("VfPpkd-Bz112c-LgbsSe material-icons-extended VxYl6");
for(var i = 0; i < buttons.length; i++)
if(buttons[i].getAttribute('aria-label') == 'Dismiss')
buttons[i].click();
Update re HOW TO APPLY THIS CODE:
Open Developer Tools (CMD+Option+I, or Menu->More Tools->Developer Tools)
Select Console tab
Paste the above code
I search here on stackoverflow articles that HTML download attribute does not work in firefox so i try all solutions and i im unable to find solutio that works...i need to do multiple file download so i try this:
<a href="http://myurl/one.txt" download>download</a>
In Chrome it downloads file...in firefox it only opens and display txt file in browser...so how to force firefox to download file?
For multiple download files i use this:
function downloadAll(urls) {
for (var i = 0; i < urls.length; i++) {
var link = document.createElement('a');
link.setAttribute('download','Balance Sheet Year 2014-2015');
link.style.display = 'none';
document.body.appendChild(link);
for (var i = 0; i < urls.length; i++) {
link.setAttribute('href', urls[i]);
link.click();
}
document.body.removeChild(link);*/
}
And then calling it using:
downloadAll(['one.txt', 'second.db']);
In Chrome it works great..when i click on download button it downloads one.txt and second.db but in firefox it only opens one.txt and not download any of two files...how to fix this?
I im using Chrome for years and is fast and more standards user friendly but firefox i don't know great to fix this..and please don't give me minus points and comments like duplicate post..because i try all of them and none works in my environment...thanks
I'm on a website that forces me to click numerous elements on the page
This is the code for the elements
<span class="icon icon-arrow-2"></span>
Is it possible to tell me the code to write into the console of google chrome to click all the elements on the page named "icon icon-arrow-2" at once?
var items = document.getElementsByClassName('icon icon-arrow-2');
for (var i = 0; i < items.length; i++) {
items[i].click();
}
Or if there is jQuery on the page:
$('.icon.icon-arrow-2').click();
var otable, orow, ocol;
otable = eval(document.all.tabmenu);
for(var ictr=otable.rows.length-1;ictr>=0;ictr--) --> error
otable.deleteRow(ictr);
There is an classic asp project in which a javascript functionand is creating two hyperlinks (add,delete).
tabmenu is a table, while in google chrome when i debug then otable.rows.length = 2 which is working fine
but unfortunately in firefox otable.rows.length = 0 , i am not able to understand it.
Need help!!
There's not document.all collection in FF. Instead of eval(document.all.tabmenu) use document.getElementById('tabmenu'), which will work in any browser.
I'm working on a project where I need to temporarily disable all hyperlinks, and then enable them again once my pop-up div is gone. I am able to successfully disable all the links using this function I wrote:
function disableHyperlinks(){
link_targets = Array();
var anchors = document.getElementsByTagName("a");
for(var i = 0; i < anchors.length; i++){
link_targets.push(anchors[i].href);
anchors[i].href= "#";
}
}
Which also saves all the URLs so it can put them back later using this function:
function enableHyperlinks(){
var anchors = document.getElementsByTagName("a");
for(var i = 0; i < anchors.length; i++){
anchors[i].href= link_targets[i];
}
}
The above code seems to work just fine, it removes all the links, and then puts them all back without any issues, however the problem is that if I run the 'enable' code after a link is clicked, its almost as if the javascript is setting the link back to the original destination and then registering the click. So despite being 'disabled' in this fashion, the link still ends up leaving the page.
The problem is demonstrated here
Click the red "L" with the white background to enable the javascript I made for selection, you'll notice anything you bring your mouse over will get a blue dashed border, I need to be able to "select" parts of the web page without redirecting to another page if a link is also clicked.. any idea how I could go about doing this properly?
(Please note I am trying to avoid JQuery)
Work on the onClick listener:
var areEnabled = false;
function toggleLinks(){
var anchors = document.getElementsByTagName('a');
for(var i=0; i < anchors.length; i++)
anchors[i].onclick = (areEnabled) ? null : function(e){ return false };
areEnabled = !areEnabled;
};
Instead of searching for many links and disabling them (which, BTW, won't help you against other clickable objects), you can create another invisible div, just below your popup on z-index that would cover entire page and catch all clicks instead of elements underneath. You can even make it semi-transparent instead of completely invisible for visual effect alerting user that "lower-level" is disabled.
I was finally able to solve my own problem by manipulating the onclick property of each hyperlink, then setting it back to what it was previously. The only problem with bokonic's response was that the onclick property was set to null to "re-enable" the link, which would then disable any javascript functionality the link had previously.
var onclickEvents;
function disableHyperlinks(){
onclickEvents = Array();
var anchors = document.getElementsByTagName("a");
for(var i = 0; i < anchors.length; i++){
onclickEvents.push(anchors[i].onclick);
anchors[i].onclick=function(){return false;};
}
}
function enableHyperlinks(){
var anchors = document.getElementsByTagName("a");
for(var i = 0; i < anchors.length; i++){
anchors[i].onclick = onclickEvents[i];
}
}