Open with Live Server in VS doesn't open web browser - javascript

`My first acquaintance with JavaScript. I'm trying to create simple webpage using Live Server.
Unfortunately, a local server can just be opened manually, but I want it to be done from VS.
I looked through my tips in Live Server settings. They are seems to be put correctly.
Probably the problem is hidden in blocking outgoing from firewall?
If you have some ideas on what's wrong, I will be glad to hear your proposals.

Related

How to prevent javascript from running twice if same page is opened in two different tabs?

I have a site made in php that calls a javascript file to check for site notifications and then send them as a browser notification (ie Mozilla's Firefox Notifications, Chrome Desktop Notifications, etc.). It works really well, and some users have asked for a chrome notification. I made a basic chrome notification that uses the same code, and it works great for when people aren't using the site. However, the problem is when they're both running at the same time. Users who are on the site and who are using the extension find themselves getting double notifications.
Is there a way to make sure that neither one's code runs if the other is active?
Thanks!
The best way to do this is to mark the alert as read on the server side. That way if I have both Firefox and Chrome open and they go to pull the alert, whoever gets there first will mark the notification as read so that the other doesn't alert it.
You Can set cookie. if one script is running then set cookie. and when you start executing your code then first check if cookie is set? if yes it means another script is running. if cookie is not set then start execution of code.
hope it helps.
Thank you.

Microsoft Word download from web server issue

I am trying to troubleshoot the following issue. A client tried to download a word document and is getting the following error.
Your organization's policies are preventing us from completing this action
for you. For more info, please contact your help desk.
I believe this issue is because of cross-domain javascript. However, the file is being downloaded from a pop-up that doesn't stay on the screen long enough for me to do anything. It is an issue with IE8 / 9.
I can not find which javascript is opening the popup let alone which javascript is being run from within the popup. I am using fiddler to try and view the http requests and that is not helping.
Is there a way for me to debug what is happening within that popup? Is there a way to debug javascript to break on a type of condition being met?
EDIT:
I have tried working on this issue on my local environment and the same issue comes up. The popup appears to first come from the same domain https://company.aj.com, then goes to a different domain https://apps.aj.com and the file is being downloaded from the apps domain.

How can I edit a js file sent by the server before it gets to my browser?

During a normal browsing session I want to edit a specific javascript file before the browser receives since once it gets there it's impossible to edit. Is there are any tool for this? For what I need it I can't just save it and edit it on my disk.
I'm ready to learn how to program it myself but if anyone can point out more or less what I have to do I'd be very grateful. I'd have to intercept the packets until I have the whole file while blocking the browser from receiving it any part of it, then edit it manually and forward it to the same port.
I don't think I can do this by just using pcap, I've read a bit about scapy but I'm not sure if it can help me either.
Thanks in advance.
You'd need to implement some sort of proxy, or hook into an existing one, and intercept the file as it's being downloaded and replace it.
Not trivial for a beginner, but a good learning project.
If you are happy to, rather then editing a file, replace it with a local one, then I would* use Charles and its Map To Local function.
Actually, "did". This helped me debug a problem with a browser and a JS file I couldn't edit yesterday.
You can probably achieve whatever it is you are wanting to do by using the firefox firebug plugin, chrome's development tools or the firefox greasemonkey plugin.
Or you could enter the files domain into your hosts file and point that domain to your local machine (running a web server), edit & save that javascript file locally and serve it from your own web server.

How to test an AJAX application that is pulling data from a live website?

I'm working on an AJAX application that pulls data from a live website, I can't replicate the complete application on my local environment at the moment so in order to test if the JavaScript code is working as expected I need to be able to bypass the same domain restriction on the browser (without making changes on the webserver) any suggestion will be greatly appreciated.
So far I have tried modifying the prefs.js in Firefox 2 and Camino including the lines suggested in this link: http://www.zachleat.com/web/2007/08/30/cross-domain-xhr-with-firefox/
Thanks in advance.
Edit 04/29/2009 3:18pm:
I agree the proxy option is definitely a way to go. But would it be possible to have a solution using just Firefox? (maybe an add-on?)
If you can change the endpoint URL you could bounce the requests through your local server, either with mod_rewrite or a simple script.
This has the advantage that you can easily log the requests and responses, and alter them (e.g. send back timeout errors, bad data and the like).
Well, for viewing the requests/stepping through the js try using Firebug.

Can I prevent user pasting Javascript into Design Mode IFrame?

I'm building a webapp that contains an IFrame in design mode so my user's can "tart" their content up and paste in content to be displayed on their page. Like the WYSIWYG editor on most blog engines or forums.
I'm trying to think of all potential security holes I need to plug, one of which is a user pasting in Javascript:
<script type="text/javascript">
// Do some nasty stuff
</script>
Now I know I can strip this out at the server end, before saving it and/or serving it back, but I'm worried about the possibility of someone being able to paste some script in and run it there and then, without even sending it back to the server for processing.
Am I worrying over nothing?
Any advice would be great, couldn't find much searching Google.
Anthony
...I'm worried about the possibility of someone being able to paste some script in and run it there and then, without even sending it back to the server for processing.
Am I worrying over nothing?
Firefox has a plug-in called Greasemonkey that allows users to arbitrarily run JavaScript against any page that loads into their browser, and there is nothing you can do about it. Firebug allows you to modify web pages as well as run arbitrary JavaScript.
AFAIK, you really only need to worry once it gets to your server, and then potentially hits other users.
As Jason said, I would focus more on cleaning the data on the server side. You don't really have any real control on the client side unless you're using Silverlight / Flex and even then you'd need to check the server.
That said, Here are some tips from "A List Apart" you may find helpful regarding server side data cleaning.
http://www.alistapart.com/articles/secureyourcode

Categories