HTTP Authentication popup doesn't shows up - javascript

I'm trying to load a snapshot of a camera and i want the authentication popup to show up when i click the button, but it doesn't work. i'm following this example https://www.httpwatch.com/httpgallery/authentication/
The popup shows up when i go to http://192.168.100.103:8080/snapshot.jpg but it doesn't when i click on the button.
<script type='text/javascript'>
function getit() {setTimeout(function(){ document.getElementById('downloadImg').src = ('http://192.168.100.103:8080/snapshot.jpg?' + Math.random().toString(10));}, 1000);}
</script>
<img id="downloadImg">
<input type="button" class="button1 buttonspace" value="Display Image" id="displayImage" onclick='getit()'>
Even though the code works when i sign in, i would like that the authentication popup shows up when i load the image.
What am i doing wrong?

Related

HTML JS Open new window with console in google chrome

This is client-side HTML. I'm just using HTML for automation.
My initial goal was to open a new window https://live.ipms247.com/login/ and then paste the values in the three login fields. All three fields have ID tags. And I can write to them from the console. For example.
document.getElementById("username").value="sample";
document.getElementById("hotelcode").value="12345";
document.getElementById("password").value="Password";
I wrote a code to copy text from parent window to child window at the click of a button.
My code is on a local file.
<html>
<head>
<script type="text/javascript">
function init()
{
popupWin = window.open('https://live.ipms247.com/login/','popupWin','');
}
function transferText()
{
popupText = popupWin.document.getElementById("username");
parentText = document.getElementById("parentTextBox");
popupText.value = parentText.value
}
</script>
</head>
<body>
<input type="text" id="parentTextBox" onkeyup="transferText();" value="Hello World">
<input type="button" onclick="init();" value="popup window">
<input type="button" onclick="transferText();" value="Transfer Text">
</body>
</html>
However, this does not work, apparently because my code is on a local file and the website is on another domain.
So my only solution to this problem, so far, is to launch the site with onlick and then focus to it. Press Ctrl+Shift+J to open the console and then paste the commands (I have code which copies them to clipboard) and hit enter.
Is there any possibility to launch the new window with the console open and focus on the console?
You can not do this because JavaScript restricts you to the user.
If you want to reach your goal, you can use the frames API

How to make a Onclick Full Page Script not work on certain Function in PHP

I was given a onclick Fullpage Popup Ad code
<script type="text/javascript" src="//dolohen.com/apu.php?zoneid=2458038"></script>
It works on the whole page and when someone clicks on any part, it opens up a popup.
Now, I don't Want it to work on the Button, cause when someone clicks it, instead of opening the youtube URL, he goes to dolohen link and has to re-click the button to go to youtube URL!
My problem is I don't want this to work on this function:
function buttonOnClick()
{
window.open('https://www.youtube.com/channel/".$channelID."?sub_confirmation=1', '_blank');
setTimeout(aTagChange, 3000);
}
<button onclick="buttonOnClick();" onmouseover="mouseOver();" onmouseout="mouseOut();">Subscribe <i id="ytb" class="fa fa-youtube-square ytb"></i></button>

How to add everwebinar form directly to page instead of opening it in POP UP?

The project on which I am working, is to open the pop up form directly into page. See below:
When you will click on first button a pop up will open:
And there will need again to click on register button to open the webinar registration form:
Here is that form:
I want to open this form on first pop up instead of register button. I got this integration code form EverWebinar:
<link href="//events.genndi.com/assets/css/register_button.css" rel="stylesheet"><div style="margin:auto;width:300px;"><div class="embedded-joinwebinar-button"><button type="button" class="btn btn-default css3button" title="regpopbox_818182175026324685_7b22b2195f"><span>Register now</span></button></div></div><script src="//events.genndi.com/register.evergreen.extra.js" language="javascript" type="text/javascript" async></script><img src="//events.genndi.com/tracker?action=registration-evergreen&webicode=7b22b2195f&version=&memberid=818182175026324685" style="visibility:hidden; height:0px; width:0px; border:none;">
I want to open the webinar form directly on first pop up instead of register button there. Is there any possible way to do it?

Window.open-ing to the same popup, even from multiple tabs

Here is a simple HTML:
<html>
<body>
<input type="button" value="open popup" onclick="window.open('http:\\www.example.com', 'popupName', 'width=100, height=100');">
</body>
</html>
so when you click on the button, a new popup will be created and no matter how many times you click it, that popup will be refreshed from now on.
Thats right. But if you opened my HTML in 2 tabulators? Then 2 popups will be opened, no matter if their names are the same. How to have actually one popup then?

trying to get my popup window blocked (need alt. to "window.open")

I'm working with the facebook SDK and it works through popups due to security issues now.
So I've got a button that deals with facebook [FacebookButton] which is hidden, and a button to test for popup blocker [PopupTester].
My code is like this,
when [PopupTester] is clicked, if a popup works: close it, hide this button, and show [FacebookButton].
or
when [PopupTester] is clicked, if popup fails, show dialogue to urge to change popup settings, keep [FacebookButton] hidden, change this button value to [Try Again].
function testPopupBlocker() {
var windowName = 'userConsole';
var popUp = window.open('http://www.whirlocal.com', windowName, 'width=200, height=200, left=24, top=24, scrollbars, resizable');
if (popUp == null || typeof(popUp)=='undefined') {
var weGood = "nope";
alert('Please disable your pop-up blocker and click the link to test again.');
}
else {
var weGood = "yup";
popUp.close();
}
}
This works great, except for the fact that this button always creates a popup, but the Facebook one is still being blocked!
Is there another method besides "window.open" to create a popup? One that is more likely to be blocked?
EDIT:
Here's my button codes
<input type="button" class="genButton testPopupButton" name="Test Popup Blocker" title="Test Popup Blocker" value="Test Popup Blocker" onclick="testPopupBlocker()" style="cursor:pointer;" />
<input type="button" class="genButton needsPopups facebookButton" name="AdvocateOnFacebook" title="Recommend <?php echo genesis_get_option('organization','child-settings');?> on Facebook" value="Recommend us on Facebook!" onclick="advocateToFriends()" style="cursor:pointer; display:none;" />
You need to legitimize the popup. It needs to be initiated by the user, and not arbitrary popup code, or else a popup blocker will stop it. Once you have a handle on the popup, then you may modify it however you like.
Try this html code out:
<a href="#" onclick="javascript:window.open('http://myurl.com/blank_page.html','userConsole','width=800,height=600,directories=no,location=no,menubar=no,status=no,toolbar=no,scrollbars=auto,resizeable=yes');">
<div class="some_div_class"><b>Click Me</b></div>
</a>
Then run your testPopupBlocker() function and see if it works a little better.

Categories