Why is my download link requiring control click to download? - node.js

I am running a pretty basic node.js server to host a site, and all of a sudden this week one of my download links started to just redirect to the index.html page instead of downloading the pdf it points to if you just click on the file. a control+click will download the file, but that is not normal behavior from what I understand with chrome.
The button is generated as so:
<button type="button" name="button">
<a href="../images/a-manill-resume.pdf" download>Downloadable Resume</a>
</button>

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a
Try setting the download attribute
<button type="button" name="button"><a download="../images/a-manill-resume.pdf">Downloadable Resume</a></button>

Related

JHipster external navigation with Angular

For me very basic navigation is not working with newly generated jHipster app.
I have 2 html pages in the root: index.html and network.html
Here is how I would like to redirect to network.html:
<a href="/network.html">
<button type="submit"
class="btn btn-info btn-sm">
<fa-icon icon="project-diagram"></fa-icon>
<span class="d-none d-md-inline">Network</span>
</button>
</a>
Unfortunately this doesn't work and I get 404 Not Found.
Can you please advise how to make external navigation working with JHipster? I have tried all examples from How to redirect to an external URL from angular2 route without using component? and nothing works
You have to modify src/main/java/{your-package}/config/WebConfigurer.java and add a resource handler for your static file. By default, all routes are redirected to index.html, which is how most SPA applications work.

How to debug unhandled win32 exception in WinJS Win8 store app

I have added Microsoft Ad SDK to my WinJS app and it crashes if I navigate away from my default.html page too fast.
<script src="/MSAdvertisingJS/ads/ad.js"></script>
If I comment out this line it does not crash. If I navigate to the default.html page and wait 10 seconds (possibly less) then it does NOT crash. It only crashes if I land on the page and immediately navigate to another page in the app. I set the destination page to be a blank html page and it still crashes.
Any ideas how I can debug further to see what is causing the issue?
Debugging it gives this call stack.
> kernel32.dll!00007ffc2c9c83a6() Unknown
combase.dll!00007ffc2e6a65b0() Unknown
twinapi.appcore.dll!00007ffc1b5847ac() Unknown
twinapi.appcore.dll!00007ffc1b58480f() Unknown
combase.dll!00007ffc2e6a61c2() Unknown
mscorlib.ni.dll!00007ffc0a8a2b2d() Unknown
I've further narrowed down the issue to being related to the link I'm navigating with.
<a href="home2.html">
<h1 class="mid">Start</h1>
</a>
<a href="home2.html">
<img src="images/d20.png" alt="d20 image" />
</a>
The first link crashes, the second doesn't. I changed the H1 tag into a span and it no longer crashes an early navigation. A few mins later it starts crashing again after adding a Div.
thanks

How to show a pop up only once in chrome extension?

Hi I need to show a pop up in chrome extension. I have set my website as a chrome extension.
Here is the use case:
When the user installs the extension, and clicks on the extension icon, it should show a pop up asking his username.
When user enters his name and login, the pop up gets closed.
This name is stored in local storage.
When user clicks the extension icon next time, it checks whether his name is stored in localstorage If not then it should again show pop up otherwise it should navigate to my website.
Now what my problem is that
When I click twice on the icon only, only then pop up appears.
After I enter name and click login pop up gets closed which is fine
When I click again on icon, actually it should navigate to the website, but in my code it again shows pop up.
When I reload the extension, it works correctly.
Please help me.
Here is my background.js
chrome.browserAction.onClicked.addListener(function(tab) {
if(!localStorage.username){
chrome.browserAction.setPopup({
popup: "userinfo.html"
}); }
else{
//navigate to website
});
here is my userinfo.html
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="test.js">
</script>
</head>
<body>
<font face="sans-serif"><b>Enter your Email ID</b></font><br><br>
<form id="userinfo">
<table><tr><td>
<font face="sans-serif"><label for="user">Email</label></font></td><td>: </td>
<td><input type="text" id="user" /></td><span id="semail"></span>
</table><br><br>
<font face="sans-serif"><input type="submit" id="login" value="Log In"/></font>
</form>
</body>
</html>
here is my test.js
window.addEventListener('DOMContentLoaded', function() {
var user = document.querySelector('input#user');
var form = document.querySelector('form#userinfo');
form.addEventListener('submit', function(evt) {
evt.preventDefault();
var userStr = user.value;
chrome.runtime.getBackgroundPage(function(bgPage) {
bgPage.login(userStr/*,pwdStr*/); });
window.close();
});
});
anyone please please help me
Let's go one by one with your problems.
1.When I click twice on the icon only, only then pop up appears.
When you click on extension icon, your browserAction.onClicked handler gets executed and it just sets the popup. It does not open it. You have to click on extension icon again to open the popup. That is why you have to click twice.
2.After I enter name and click login pop up gets closed which is fine.
This is because you are redirecting to a new page which closes the extension popup.
3.When I click again on icon, actually it should navigate to the website, but in my code it again shows pop up.
Since you have setup popup for extension click, it has over-ridden the chrome.browserAction.onClick handler which is why you are not able to navigate to your website.
4.When I reload the extension, it works correctly.
This is because after reload, your chrome.browserAction.onClick is not over-ridden by popup and since login credentials are present in localstorage, your code does not over-ride it.
Solution1
In background script, check if the credentials are stored in localstorage then do not set the popup, else set the popup.
Add the handler chrome.browserAction.onClick to always navigate to your website. You know that if popup opens then your handler will not be executed.
When you store the credentials in localstorage and if they are correct, remove the popup.
To remove popup, you can try chrome.browserAction.setPopup({popup: ""});
From chrome.broswerAction API
onClicked
Fired when a browser action icon is clicked. This event will not fire if the browser action has a popup.
Solution2
Popup has the same permissions which background scrips have. So instead of defining chrome.browserAction.onClicked event, just write your code in popup script.
Check the localstorage, if credentials are present, create a new tab and open your page and close the popup with window.close()
Otherwise don't close the popup.
PS: I have not tried it. Just giving you an idea.

"https://fls.doubleclick.net" tracking downloads "http://www.googleadservices.com/pagead/conversion.js"

I had this Google floodlight code on a secure page in one of the websites I maintain. This content is inside and iframe which in turn is inside :
<script type="text/javascript">
document.write ('<IFRAME src="https://fls.doubleclick.net/activityi;src=XXXXX;type=12312;cat=084;qty=1;cost=$iTotal;?" width="1" height="1" frameborder="1" style="display:none"
</IFRAME>')
</script>
recently IE issued a message stating the page has insecure content. Inspecting the page with fiddler I can see that now the Google server that receives the floodlights also sends back a javascript library:
"http://www.googleadservices.com/pagead/conversion.js"
which is causing the insecure content message.
Has this happened to you too? Any idea how to fix it?
I found a tag I didn't knew on doubleclick:
<img src="https://gan.doubleclick.net/gan_conversion?advid=K123456&oid=12345&amt=123.45" width=1 height=1>
but It's not very clear if it does the same thing.
Ideas?
In the corrosponding Google Floodlight activity, you'll want to check the box that says "Secure Servers Only (https)".

From popup.html, how can I run a javascript function by button onclick?

I'm trying to build an extension for Chrome, but I'm a newbie and I'm having trouble understanding the Docs provided by Google. I want the extension to have a popup that shows a few buttons, and when a button is clicked, I want to run a script.
This is my setup:
popup.html
<button id="test1" onclick="getSite();">button 1</button>
<button id="test2" onclick="getSite();">button 2</button>
content_script.js
function getSite(){alert('getSite works!');}
I'm having trouble understanding how to use the chrome javascript api, as I see others saying use chrome.tabs.executeScript, but I can't figure out where that line goes. Can anyone help me? I'll give you a cookie! or just an upvote.. or maybe both?
You haven't mentioned on which page you want your scripts to run onclick, in Popup.html page or the page on which user is currently working on the browser. If it is just the popup.html page in which you want to execute your script, include them in popup.html page itself.
If however you want to execute them on the user's browser page, You will have to pass a message to your background page, which in turn will execute chrome.tabs.executeScript with current tab's id and {file: 'yourjsfile.js'} as arguments.
I think you are having this problem because of restrictions imposed by the Google Content Security Policy. It mentions that iniline javascript like the one that you have mentioned in you code will not be executed. Try removing the onclick="getSite()" from your HTML markup to content_script.js. Use addEventListener function to attach the event to the button.

Resources