jQuery function to override system default browser and my own? - javascript

I have a C# project, which has created an Outlook 2010 plugin. On click of the plugin a web based form loads inside the Outlook. The project loads form using the system default browser. I checked the project code and saw that jQuery.browser method is used to detect the system default browser specifics, and then use it in the program.
Now, I want to make a change to this code. All I want is to render the form using a browser of my choice, and not the system default one. Is there any jQuery function to override the default browser and use a custom one?
I am new to jQuery, and till now the online search I did, and articles I read, I didn't find any such method.
Your help help is appreciated!

Since the browser is the one running jQuery, jQuery cannot decide which browser runs it. Also, it is unaware of the context in which it's running, which is inside outlook.
To change this behavior you need to control it through outlook, though I highly doubt ms made chrome/ff available inside outlook.

Related

Is it possible to create a react app that runs when Javascript is disabled in browser?

I am developing a reactjs site and I want to make that site running even when the javascript is disabled in browsers. Is it possible? how to develop a react site that runs on both conditions (Enabled and disabled of Javascript) for ex: fb, StackOverflow are running even javascript is disabled how it happens?
React is a JavaScript framework for the front-end. Which means it executes in the browser. If you disable JavaScript in the browser, React doesn't work anymore. Just in the same way if you delete Photoshop from your computer, you can't open .psd files anymore.
If you really must support browsers without JavaScript (which most people don't), you need to build your app to work with plain old HTML based navigation (think links, forms etc).
It's possible to use React (for people with JS enabled) and a fallback for those without, this approach is called Progressive Enhancement. Might be useful to you: https://softwareengineering.stackexchange.com/questions/25969/should-i-bother-to-develop-for-javascript-disabled
First thing, React is a javascript library so it depends on Javascript. But you can use server side rendering like Next.js and render the content on server side.
But still user cannot use any react feature in browser.
It's good to render the initial content on screen.
Stackoverflow renders the initial content on server and sends the initial rendered content to the browser.
It's also good for SEO.

jQuery dependency on asp.net mvc site

I have an Asp.NET MVC 4.0 site that uses jQuery 1.11.1. I had an issue where some of the javascript on an end users browser (IE) was not working. For some reason, they had version 1.7.x of jQuery. I've been coding for a long time, but I'm relatively new in the web development area.
Why would the browser not download my copy of jQuery from the server? Is there a way to force the browser to get my version?
Thanks!
If the client is loading your site normally (calling an endpoint on your server) then there is no way they could load any version of jquery other than the one you have included in the script tag on your web page.
If you are doing something fancy like providing a widget that your user embeds in a page then indeed, depending on the order in which the scripts get loaded, the browser might wind up with a different version of jquery.
If you're doing the latter there are methods you can use to get a particular version of jquery for your code. See here for a start:
Include a specific version of JQuery and a plugin without conflicting with the page's JavaScript library?
Based on the comments below, you might also have other libraries in your application that also load jquery. The $ variable will get the last version of jquery to load. I would have thought that every browser would load them in the same order, but perhaps on older copies IE things happen differently (or perhaps there are paths through your app that load things in a different order).
If any of that's true then you'll have to use one of the techniques above. I'd also look into whether you can force kendo not to take over $.

How can I simulate "CTRL +S" keypress in Javascript

I have a page with HTML/JavaScript code I want to export to an HTM file when the user presses the export button on the page. I basically just need to find a way to trigger Ctrl+S to execute the Save Page dialog window. I have searched all over and can't seem to find any thing for this that allows JavaScript to simulate that key press sequence.
TL:DR - Does anyone know how to simulate CTRL+S key press in JavaScript/jQuery
Use the saveDocument() method. Docs for it here.
Edit: That only works in Firefox.
I don't think Javascript can do that. There is something for printing but not for saving.
What you can do you create a hint for the browser that the file is an attachment.
You need to send some HTTP headers. You can for example do that with PHP:
header('Content-disposition: attachment');
Maybe .htaccess works also if you don't want to use PHP. You can look that up.
If you want the browser to save the user's page preserving changes in the DOM, this might be beyond the scope of JavaScript, which aims to provide interaction with the page itself, not the environment it's working in.
On some devices this might even be inapplicable - saving pages in Android browsers it not that straightforward and not always possible.
Still, if you're looking just for a working solution for several desktop browsers, you could look at TiddlyWiki, which is a kind of a "local wiki", content on which are kept client-side and saved with the page. Saving is implemented in Java (not JavaScript!) applet distributed with the page. Kind of a web-based browser-based application.

Is it safe to use jQuery and jQuery-UI with Google Chrome extensions?

I'm going to write a simple chrome extension using jQuery and jQuery UI. Before I start, however, I want to know: what might happen if a web page that my extension is going to interact with also uses this libraries? Can there be any conflicts (e.g. CSS for my jQuery-UI theme messing up the page's jQuery-UI theme)?
Javascript is sandboxed so there will be no conflicts, but CSS isn't, so any styles on parent site will affect your styling and vice versa (aka a nightmare).
Yes there can be conflicts, however you can prevent them. When you are setting up a theme, you need to download it with a namespace(you can find that setting in the right column of the jquery ui custom download page), and then use that namespace in your extension. The only possible issue at that point is if the site that is being viewed uses the same namespace that you choose, so make sure you choose something that won't have that problem.
It depends what type of extension you are making. If you are making a replacement for an existing Chrome page, well, it will be a full replacement (http://code.google.com/chrome/extensions/override.html). If it is a popup through either page (http://code.google.com/chrome/extensions/pageAction.html) or browser (http://code.google.com/chrome/extensions/browserAction.html) action, then again, you will have no conflicts because all of your code is sandboxed to itself.
The only time I can think of that you will run into an issue is if you are using content scripts (http://code.google.com/chrome/extensions/content_scripts.html), or actually injecting your code into the page by other means. Then, yes there could be conflicts, as the browser now runs your code along side the web sites code. Depending on what you need to do, you could try injecting your code as an iframe, but that will also prevent it from interacting with said web page.
<iframe src="yourPageUrl" height="iframeHeight" width="iframeWidth" style="border:none;"></iframe>
So without knowing what your extension's purpose was, it would be hard to know exactly how to help.

Interacting with Local webpage through Application in real time?

I want to interact with my local HTML page through my C++ application. Just like using java script console, we can edit a page in real time, e.g
document.getElementById('divlayer').style.visibility = 'hidden';
Similarly i want to call such functions in real time through my application.
Can you give me some idea if there is a way to accomplish this job?
I am using Google Chrome at the moment.
Do i need some plugin, but how can i make plugin to interact with my application then?
Also, i head about JQuery, can this be done using JQuery? Or do i have to try some server mecahnism may be using Ajax??
I know that you can control your IE browser with COM on Windows, and you can interact with the page with it. But I didn't try it with C++, I just use it with Python and it works well. May be you'd like to check it out.

Categories