I have different links which opens another page in a popup.The popup function is like this.
function popUp(URL) {
eval("lesson = window.open(URL, 'lesson', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=600,left = 250,top = 50');");
}
When links are opened,its working fine in mozilla.When links are opened in chrome its giving me the following content
The filename has spaces.I dont if this is happening because of this space or not because I am not able to rename or upload the files into that server
Related
I would like to check if an external link contains playable media before opening the link in a new tab. I am attempting to do this in an if else format so that I can modify the link if it does not contain playable media.
I am struggling to figure out how to check for this if both links end in .mp4 in the URL. Essentially one link gets an XML error and the other does not, and I am trying to account for these differences and dynamically adjust the link before opening it. I've also just tried to check for strings on the new page to see if there is an XML error, but the script stops as soon as a new tab is opened with window.open, and chrome.tabs.create doesn't seem to work.
I'm new to Javascript. Any advice would be helpful.
//var win = window.open(modifiedLink, '_blank').focus();
chrome.tabs.create({
url: modifiedLink,
selected: true,
})
var checkForErrors = document.querySelector("body > div.header > span").innerHTML;
if (checkForErrors.includes("This XML file does not appear to have any style")) {
modifiedLink = modifiedLink.replace('/ask_video/', '/encoded/')
window.open(modifiedLink, '_blank').focus();
}
i have this iframe here, and i want to doanload the window page with pdf inside, js function print() only shows the page, i want to download it automatically, bellow is the full code (i tryed with jspdf too).
<iframe id="conteudoIframe" src="https://eproc.trf4.jus.br/eproc2trf4/controlador.php?acao=acessar_documento_publico&doc=41625504719486351366932807019&evento=20084&key=0562cc6eddee0cc4a81dd869f92328dceab34deeaa59f4a33c43da6361cf42d6&hash=08920b364dc8433ad071d6b10c7e3817" name="superior" width="100%" height="560px"></iframe>
<script>
downloadPdfFromIframe();
function downloadPdfFromIframe() {
var script = document.createElement('script');
script.src = 'https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js';
document.head.appendChild(script);
script.onload = () => { setTimeout(download(), 20000); };
function download() {
var myIframe = document.getElementById("conteudoIframe").contentWindow;
myIframe.focus();
myIframe.print();
myIframe.close();
var pdf = new jsPDF();
pdf.fromHTML(myIframe);
pdf.save('test.pdf');
return false;
}
}
</script>
Iframes are only a window to remote objects thus while viewing they are showing both the already downloaded html surround and the already downloaded PDF but the PDF is independent It may be downloaded before or after the frame, you can see the pdf behind the print html dialog. So the PDF is in a different application as seen in the second browser view of your HTML.
Thus you have to save/print either one at a time. Frame object or Pdf object, to get both is not impossible, just needs to be done with a suitable application (not browser). So just like here I have ScreenShots, those canvases can be easily saved or printed as PDF.
A Chrome based Browser viewing the iFrame for printing
A Firefox based Browser viewing the iFrame to print using any other method like open in a second application window.
If you need to download the two parts outside a browser then use two Download Commands so here is my.pdf
curl -o my.pdf "https://eproc.trf4.jus.br/eproc2trf4/controlador.php?acao=acessar_documento_implementacao&doc=41625504719486351366932807019&evento=20084&key=0562cc6eddee0cc4a81dd869f92328dceab34deeaa59f4a33c43da6361cf42d6&hash=08920b364dc8433ad071d6b10c7e3817&termosPesquisados="
I'm creating a script in Photoshop using JavaScript that I want to open chrome for all types of windows users and open a link in chrome. After the chrome is open and link is insert I want to complete a form with values that I know and submit the form, the new link that is generated I want to open and download the image.
Using my code the error I received on Photoshop is "the window is undefined", but if I delete window.open line the chrome open using the script in Photoshop.
Here is my code. Any solutions?
var commandtoRun = "C:\\PROGRA~1\\Google\\Chrome\\Application\\chrome.exe";
app.system(commandtoRun,"","","open","1");
var windowObjectReference;
window.open(
"https://www.yourURL.com", "_blank");
I did it with
window.onload = function() {
window.open("https://www.w3schools.com");
}
//openRequestedPopup();
//file.remove();
var site="//mylinkwithform"; //your side
if ( $.os.indexOf("Windows") != -1 )
{//SYSTEM IS ONE OF THE WINDOWS
app.system("cmd.exe /c\"start http://"+site+"\"" );
}
else{//MUST BE MAC
system.callSystem("open http://"+site);
}
How i insert the values in the form from the site and submit the form?
I'm currently writing a chrome extension. I have a button that should open the settings.html file in my extensions root directory. But it gets blocked by chrome saying "requests to the server have been blocked by an extension" and "ERR_BLOCKED_BY_CLIENT". I have tested it, and no addon blocks it. But if I open it by creating a new tab and pasting the link in, it works and shows the html file.
Heres my code:
function gotosettings_first() {
console.log("TO THE SETTINGS!!!");
var settings_url = chrome.runtime.getURL("settings.html");
//console.log(settings_url);
//window.location.href = settings_url;
var sw = window.open(settings_url, "_blank");
sw.focus();
}
Thanks for helping
I have a Chrome extension that allows you to download data from certain sites.
For the past few days, I have attempted to add a feature that will download data from the sites when they are linked from other sites without having to visit the page and click the addon created download button IF the link to the site ends with #ndslink.
I figured out a solution, but it is INCREDIBLY sloppy and I am looking for a better way to implement this.
Here's the behavior:
Site A links Site B with an href ending in #nddownload. The link is clicked.
The extension disables the default action (open a new window), and instead creates an iframe on Site A and loads the linked URL into the frame.
The extension now runs Site B's content script, which specifically looks for #nddownload in the url, and, when found, proceeds to download some data that would normally be downloaded through a manual "Download" button added onto the page via the extension.
Here is my code.
Site B's content script:
var decklist = [];
$('.col-name').each(function(i, el) {
// IRRELEVANT CODE TRIMMMED
}
});
var data = decklist.join("\r\n");
var saveData = (function () {
// IRRELEVANT CODE TRIMMMED
}());
$(document).ready(function(){
var html = $('.t-deck-title').html();
fileName = $('.t-deck-title').text() + '.txt';
//html = html.replace(/hearthstonedeckdl/, '</br><a class="download" href="#download">DOWNLOAD</a>');
$('.t-deck-title').html(html);
if (window.location.href.indexOf("#ndslink") > -1) {
saveData(data, fileName);
}
$(document).on('click', 'a[href="#download"]', function(){
saveData(data, fileName);
});
});
Script loaded on all URLs (incl Site A):
var $jg = jQuery.noConflict();
$jg(document).ready(function(){
$jg('a[href$="#ndslink').click(function(e) {
e.preventDefault();
});
$jg(document).on('click', 'a[href$="#ndslink"]', function(){
//saveData(data, fileName);
var frameurl = $jg(this).text();
$jg('body').prepend('<iframe id="nddownload" />');
$jg("#nddownload").attr("src", frameurl);
//e.preventDefault();
// Send link to background and download.
});
});
I feel as if I am committing a horrible sin by going this route, but being new to Chrome extensions and generally being inexperienced I could not find a proper way to handle this. I've probably also broken my extension 10 different ways while attempting to do this so a real solution would be much appreciated.
I'm also actually unsure how to go about properly destroying the iframe once the saveData function completes.