Force a link in I.E. to open in Firefox - javascript

I have two links in a corporate intranet site, built in Sharepoint, that I need to link to Firefox. The links are to an external site that does not work in I.E. However, the corporate browser is I.E., so that's what most people see.
I found the below code that works when I have one link. How do I get it to work for two links?
Here's the code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>HTA Test</title>
<hta:application applicationname="HTA Test" scroll="yes" singleinstance="yes">
<script type="text/javascript">
function openURL()
{
var shell = new ActiveXObject("WScript.Shell");
shell.run("http://www.google.com");
}
</script>
</head>
<body>
<input type="button" onclick="openURL()" value="Open Google">
</body>
</html>

You can modify your script to something like:
<script type="text/javascript">
function openURL(url)
{
var shell = new ActiveXObject("WScript.Shell");
shell.run(url);
}
</script>
</head>
<body>
<input type="button" onclick="openURL('http://www.google.com')" value="Open Google">
<input type="button" onclick="openURL('http://www.yahoo.com')" value="Open Yahoo">

Related

Why XSS doesn't work at a created HTML Page?

Hello I'm practice on XSS-Attack in an HTML Page that I created, but it doesn't work for me.
This is the HTML Page:
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Try to XSS this!</title>
<script language="javascript" type="text/javascript">
var send = function () {
var data = document.getElementById("msg").value;
document.getElementById("demo").innerHTML = data;
}
</script>
</head>
<body>
<p>Enter an XSS exploit here:</p>
<textarea id="msg" rows="10" cols="20"></textarea>
<br />
<input type="button" id="send" onclick="send();"/>
<br>
<p id="demo"></p>
</body>
</html>
This is the XSS-Exploit (I write it in the <textarea>):
hello</p>
<script>alert("XSS");</script>
<p>
And this is the result (I show the <p id="demo"></p> part):
<p id="demo">
"hello"
<p></p>
<script>alert("XSS");</script>
<p></p>
</p>
And the command alert("XSS"); doesn't work. What did I do wrong?
Script tags only run on page load; when you dynamically inject them into the page, script tags aren't run. The common bypass to this is to use onerror or onload like <img src=x onerror='alert(1)'> or <svg onload='alert(1)'></svg>

Move a popup window using setInterval() in javascript

I'm trying to make a window pops up and then moves continuously using setInterval(). It pops up but it doesn't move.
I'm using all the html files in the same directory.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>popup</title>
</head>
<body>
<input type="button" name="" value="new window" onclick="newWin();">
<input type="button" name="" value="stop window" onclick="stopWin()">
<script type="text/javascript">
var win1;
var interv;
function moveWin(){
win1.moveBy(100, 100);
win1.focus();
}
function newWin(){
win1 = window.open('new.html', 'win1', 'width=200, height=150');
win1.focus();
interv = setInterval(moveWin, 1000);
}
function stopWin(){
clearInterval(interv);
}
</script>
</body>
</html>

DOM with javascript not working

I'm newbie to web programming and I can't understand why the following code doesn't work.
It is supposed to remove permanently the content of the div element when the button is pressed, but it disappears for a while and then reappears.
The code is the following:
<!DOCTYPE html>
<html lang="es">
<head>
</head>
<body>
<script type="text/javascript">
function prueba(){
document.getElementById('uno').innerHTML="";
}
</script>
<div id="uno">CONTENEDOR UNO</div>
<form onSubmit="prueba()">
<input type="submit" value="Entrar" >
</form>
</body>
</html>
I believe what's happening is that your button is submitting a form, which sends the form to the web server then reloads your page. So:
Your "onSubmit" JS runs immediately and clears the div content.
Your page reloads and the content comes back.
Try something like this instead of a form (i.e. remove the surrounding form tag):
<button onclick="prueba()">Entrar</button>
Try this. You don't need a form to hide a DIV
<!DOCTYPE html>
<html lang="es">
<head>
</head>
<body>
<script type="text/javascript">
function prueba(){
document.getElementById('uno').innerHTML="";
}
</script>
<div id="uno">CONTENEDOR UNO</div>
<input type="button" onclick="prueba()" value="Entrar">
</body>
</html>
DEMO : http://jsfiddle.net/36pvts4t/2/
try this , for me this is working .This code is remove the text in div with id "uno" , on form submit .
<!DOCTYPE html>
<html lang="es">
<head>
</head>
<body>
<script type="text/javascript">
function prueba(){
console.log("Inside the function preueba ");
document.getElementById('uno').innerHTML="";
}
</script>
<div id="uno">CONTENEDOR UNO</div>
<form action="#" method="get" onSubmit="prueba()" target="_blank" >
<input type="submit" value="Entrar" >
</form>
</body>
</html>

javascript changing value of form element and socket.io

I have the following code that works:
<html>
<head>
<script>
function loaded(){
oFormElement = document.forms['test form'].elements["txtStatus"];
oFormElement.value = "just loaded";
}
</script>
</head>
<body onload="loaded()">
<p>my first socket.io test</p>
<form id = "test form">
<input type="text" id ="txtStatus" value="">
</form>
</body>
</html>
now, if I include the reference to socket.io, it stops working
<html>
<head>
<script src="socket.io/socket.io.js">
<script>
function loaded(){
is this because socket.io handles from elements in it's own way, or is because the browser cannot find socket.io ? Is there any way to debug this/fix this ?
You need to close the first <script> tag...
<html>
<head>
<script src="socket.io/socket.io.js"></script>
<script>
function loaded(){
// ...

how to close a browser having pdf inside it

i have an browser with pdf which is opened on clicking "viewPDF" button in the main page of an asp.net and c#.net application.
On clicking the "viewPdf" button i am opening the pdf in the browser using the javascript as below:
<script language="javascript">
function openpdf()
{
var pdfobj= window.open('epcrpdf.aspx');
}
</script>
in the design page.
<input id="btnTakeAction"
class="Button"
type="button" value="View Pdf"
onclick="javscript:openpdf();">
The problem is i also have a log out button in the mainpage, on cliking the log out button i have to close the childwindows like the browser containing pdf.
when i try to close the browser containing using javscript as below i face a problem of "Access is denied".
pdfobj.close();
but other browsers which does not contain pdf gets closed with out any error message.
This has worked for me:
<%# Page Title="Home Page" Language="C#" AutoEventWireup="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head id="Head1" runat="server">
<title></title>
<script type="text/javascript">
var wnd = null;
function openPdf() {
wnd = window.open('test.pdf');
}
function closePdf() {
if (wnd != null) {
wnd.close();
}
}
</script>
</head>
<body>
<form id="Form1" runat="server">
<input type="button" name="open" value="Open" onclick="openPdf();" />
<input type="button" name="close" value="Close" onclick="closePdf();" />
</form>
</body>
</html>

Categories

Resources