Having problem to open form in new window, script is pulled from external service.
Take a look CODE on JSfiddle
regards
You can add a target attribute to the form after its been rendered;
<html>
<head>
<script type="text/javascript">
function fixform() {
//ism is created by the opentable.com script
document.forms["ism"].setAttribute("target", "_blank");
}
</script>
</head>
<body onload="fixform();">
<div id="book-table">
<div id="OT_searchWrapperAll">
<script type="text/JavaScript" src="http://www.opentable.com/ism/?rid=35449"></script>
<noscript id="OT_noscript">
Reserve Now on OpenTable.com
</noscript>
</div>
</div>
</body>
</html>
Update Try removing the onload="fixform();" and use the jQuery equivalent;
$(document).ready(function() {
document.forms["ism"].setAttribute("target", "_blank");
});
Related
Essentially, all I want to do is open an external web page after the current page is loaded via java script.
open my page -> javascript tells browser to open external page -> external page being loaded into the broser
How may I accomplish this?
you may use this
<html>
<head>
<script type="text/javascript">
function load()
{
window.location.href = "http://externalpage.com";
}
</script>
</head>
<body onload="load()">
<h1>Hello World!</h1>
</body>
</html>
<html>
<head>
<script type="text/javascript">
function load()
{
window.location.href = "http://externalpage.com";
}
</script>
</head>
<body onload="load()">
<h1>Hello World!</h1>
</body>
</html>
Hope it should be window.location. Check the code.
Technically you can:
location.href = "http://example.net/";
… but you should perform an HTTP redirect instead as that is more reliable, faster and better food for search engines.
You can also use the "open" method to open the source file or url on a new window.
window.open("anyfile.*");
or
window.open("http://anylocation.com");
Hi please try this code for page loading time we will redirect whatever u configured the urls.
<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {
window.open('https://google.com');
}
</script>
</head>
<body onload="myFunction()">
</body>
</html>
<body>
<script>
document.body.innerHTML += 'Link';
document.getElementById("link").click();
</script>
<body>
I am trying to translate my web page automatically using google translator. After the full web page get loaded 3 seconds later i am performing a jQuery click event on select option. The option i want to get selected is get selected by the event but no translation is happening. But if i select on my own translation works on my page.
Here is my code:
<!DOCTYPE html>
<html lang="en-US">
<body>
<h1>My Web Page</h1>
<p>Mi nombre!</p>
<p>Translate this page:</p>
<div id="google_translate_element"></div>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element');
}
</script>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<p>You can translate the content of this page by selecting a language in the select box.</p>
<script type="text/javascript">
$( document ).ready(function() {
setTimeout(function(){
$('.goog-te-combo').val("bn").click();
}, 3000);
//$('.goog-te-combo').val("bn").click();
});
</script>
</body>
</html>
You're not clicking the element. Add .click() on the select
Try $('.goog-te-combo').val("bn").trigger('click')
I'm using iframe to load lumextech.com as default src in a frame when i search and move to other webpage using lumextech.com But still in the iframe src its display lumextech.com only i wanted to capture url of page that has loaded in iframe...Notes: I don't have Control on lumextech.com....
My Code:
<! DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery.min.js"></script>
</head>
<body>
<section>
<h3> welcome to Iframe</h3>
<script type="text/javascript">
$(function(){
$('#submit').click(function(){
$url = $('#iframeContent').attr('src');
$('#demo').html($url);
});
});
</script>
<input type="submit" id="submit" value="showUrl"/>
<div id="demo"></div>
<iframe id="iframeContent" src="http://lumextech.com" style="min-height: 500px; min-width: 500px;"></iframe>
</section>
</body>
</html>
You had a typo in your src insert function. Extra white space in the string. Work good on this Codepen
$('#frameid').attr('src', 'http://lumextech.com/');
So I have a basic html page and basic Javascript in the head. I'm trying to redirect using Javascript once the function is activated through onClick but window.location.href wont work. window.alert works and everything else.
HTML
<html>
<head>
<title>Testing Aff Links</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript">
function myfunc(){
window.location.href="http://youtube.com";
}
</script>
</head>
<body>
Link Link #1
</body>
</html>
You need to return false from the onclick attribute to prevent the default action:
Link Link #1
You are redirecting twice. Change it to:
Link Link #1
Why is it so that when you use window.parent.showMessage("Video Is OK"); inside a .js file you've included on a page, it won't work, but only if it's on the page itself..?
Can you fix this?
There are two scenarios that I can think of where you'd want to use window.parent. The first is when you have a window open another window using window.open. The other is where the first window uses an iframe to load a page. In the former case, it appears as though you actually want to use window.opener, as ukostin has said. In the latter case, window.parent works fine. Both methods work properly whether the code is inline or loaded from an external JS file. Here are some tests:
POPUP
parentWindow.htm:
<html>
<head>
<script>function showMsg(msg){alert(msg);}</script>
<body>
Open
</body>
</html>
externalWindow.js:
function showMsgExternal(msg){window.opener.showMsg(msg);}
childWindow.htm:
<html>
<head>
<script>function showMsgInline(msg){window.opener.showMsg(msg);}</script>
<script src="externalWindow.js"></script>
</head>
<body>
Inline
External
</body>
</html>
IFRAME
parentFrame.htm:
<html>
<head>
<script>function showMsg(msg){alert(msg);}</script>
</head>
<body>
<iframe src="childFrame.htm" width="300" height="100"></iframe>
</body>
</html>
externalFrame.js:
function showMsgExternal(msg){window.parent.showMsg(msg);}
childFrame.htm:
<html>
<head>
<script>function showMsgInline(msg){window.parent.showMsg(msg);}</script>
<script src="externalFrame.js"></script>
</head>
<body>
Inline
External
</body>
</html>
Try to use window.opener as link to the parent window.