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/');
Related
I am making a chrome extension and I have multiple buttons which open different tabs. Unfortunately for some reason when I click the Seqta button it opens the tab 3 times and with the maths book it opens the tab twice. I'm not sure what is wrong but I have put the html and javascript below.
HTML
<!DOCTYPE html>
<html>
<head>
<style>
body{
background-color: #263238;
width: 300px;
height: 500px;
}
</style>
</head>
<body>
<div id="buttons">
<div id="buttonDivSEQTA">
<button type="button" class="button" id="seqta" >Seqta</button>
<script src="popup.js"></script>
</div>
<div id="buttonDivMATH">
<button type="button" class="button" id="maths">Maths Textbook</button>
<script src="popup.js"></script>
</div>
<div id="buttonDivHASS">
<button type="button" class="button" id="hass">HASS Textbook</button>
<script src="popup.js"></script>
</div>
</div>
</body>
</html>
Javascript
var button = document.getElementById("seqta");
button.addEventListener("click", function(){
chrome.tabs.create({url:"https://learn.bcgs.wa.edu.au"});
});
var button = document.getElementById("maths");
button.addEventListener("click", function(){
chrome.tabs.create({url:"https://jacplus.com.au"});
});
var button = document.getElementById("hass");
button.addEventListener("click", function(){
chrome.tabs.create({url:"http://www.pearsonplaces.com.au/User_Login.aspx"});
});
It would be great if someone could help me out
You entered mutliple script calling, remove <script src="popup.js"></script> from the body and place it in right before .
As others say you have the script called three times.
You need to delete the two of them and move the call into the <head>-section with whatever is located there. It is the most common and also then you know exactly where your scripts are located and you doesn't have to search your entire page for the script.
For example:
<head>
<script src="popup.js"></script>
</head>
For reference:
JavaScript in <head> or <body>
You can place any number of scripts in an HTML document. Scripts can be placed in the <body>, or in the <head> section of an HTML page, or in both.
W3Schools
For those who are interested there is an old discussion on where to put the jQuery/JavaScript scripts - read it here
I really don't understand why IE (only, ok for any other browser) gives me HTML1402: Character reference is missing an ending semi-colon “;” with the following code:
<!DOCTYPE HTML>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
</head>
<body>
<span id="here"></span>
<div id="url_iframe">https://www.google.com.br/search?q=ie+html+1402+with+jquery&ie=utf-8&oe=utf-8&client=firefox-b&gws_rd=cr</div>
<script>
var url_iframe = jQuery('#url_iframe').text();
jQuery('#here').append('<iframe src="'+encodeURIComponent(url_iframe)+'" scrolling="no" frameborder="0" width="320" height="300"></iframe>');
</script>
</body>
</html>
Some one know how to fix it, so that stop to appear in console?
I tried without encodeURIComponent and same error.
The URL is just a sample, I konw that won't work, it's a test for an issue of a very big and complex code, all I discover was if I change it to iframe instead of using jquery, no warning shows, but I need to do it with jquery, because of the data before my append in the real web application.
Assuming that the error had to be a MS bug, I discovered that I was right and all I needed was to swap the div for input:
<!DOCTYPE HTML>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
</head>
<body>
<span id="here"></span>
<input type="hidden" id="url_iframe" value="https://www.google.com.br/search?q=ie+html+1402+with+jquery&ie=utf-8&oe=utf-8&client=firefox-b&gws_rd=cr"/>
<script>
var url_iframe = jQuery('#url_iframe').val();
jQuery('#here').append('<iframe src="'+url_iframe+'" scrolling="no" frameborder="0" width="320" height="300"></iframe>');
</script>
</body>
</html>
If someone know how to do it with div, I will be glad if share here...
For certain reasons, I have it so a div will contain code that I want an iframe to load:
<div id="MyDiv">
<html>
<head>
</head>
<body>
<h1>Hi</h1>
</body>
</html>
</div>
<iframe id="MyFrame"></iframe>
My Javascript to get the text (the code) within the div above:
var DCode = document.getElementById("MyDiv").innerHTML;
My Jquery to add the code to my iframe:
$('#MyFrame').contents().find('html').append(DCode);
When I view the document in my iframe, I see the html from the div inside but wrapped with double quotes and in the body. How can I get it to display as a page?
One thing I realized when using an alert box to display the code, the "<" are shown as the escape characters: & l t ;
Few things to consider -
1) Contents in MyDiv - <head> and <body> tags starts but do not end.
2) var "DCode" holds innerHTML but jquery appends "DString".. Variables are different.
Is it a typo in asking the question?
I could not reproduce your issue. Following code works fine for me -
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
function copy()
{
var DCode = document.getElementById("MyDiv").innerHTML;
$('#MyFrame').contents().find('html').append(DCode);
}
</script>
</head>
<body onload="copy();">
<div id="MyDiv">
<html>
<head></head>
<body>
<h1>Hi</h1>
Div body
</body>
</html>
</div>
<iframe id="MyFrame"></iframe>
</body>
</html>
Let's say we have this markup:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf8" />
<title>project.js</title>
<script src="project.js"></script>
<script>
</script>
</head>
<body>
<h1>some project — javascript & html tests</h1>
<hr />
<p>
testing 123
</p>
</body>
</html>
I know that there are .prependChild(), .appendChild(), .innerHTML, etc, properties and methods, but what I am looking for is how to add (append) contents after the </body> tag closure?
I need this, without using jQuery — is it possible?
If you use 'id'.you can use these property:
document.getElementById('id').nextSibling;
document.getElementById('id').previousSibling;
It won't work in some browser because content after body is not "legal". Anyway, this would be:
document.body.parentNode.appendChild(document.createTextNode('text after body'));
document.body.parentNode.appendChild(document.createComment('comment after body'));
http://jsfiddle.net/yVKk6/ and inspect the Result frame.
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");
});