So I have this:
<script>
window.print();
</script>
I want to print this url's image:
http://www.somefancyurl.com/labels/postage/45029dd.png
The page displays nothing but the image I am wanting to print.
I tried:
<script>
window.print('http://www.somefancyurl.com/labels/postage/45029dd.png');
</script>
But that didn't seem to change anything.
Thanks to some searching, I came up with this:
function printLabel(){
popup = window.open();
popup.document.write('<?php echo $order->shipmentLabel; ?>');
popup.print();
return false;
}
But that tries to print out <?php echo $order->shipmentLabel; ?> not the actual image.
In page, write html code like
<html>
<body>
<img src='http://www.somefancyurl.com/labels/postage/45029dd.png' />
</body>
</html>
and write script as
<script>
window.print();
</script>
You can't print an image directly.
You should do it this way:
<script>
window.print();
</script>
<img src="http://www.somefancyurl.com/labels/postage/45029dd.png" />
You can also do it in a new window.(popup)
Related
I've been working on this little script where the translated text is supposed to return in its original position. Everything seems fine, but the js is still unable to find the window object. Is there anything wrong in code? I have tried newXWin.document too, but no use. Please assist.
<?php
?>
<html>
<head>
<script>
function DoMagic()
{
var newWin = window.open("https://translate.google.com/#auto/es/This%20is%20a%20test%20sentence.%0AI%20think%20I%20should%20try%20this.","newXWin","width=500,height=600");
}
function GetText()
{
alert(window.opener.document.getElementById("result_box").innerHTML + "");
}
</script>
</head>
<body>
<div id='toDiv'></div>
<a href='#' onclick='javascript:DoMagic();'>Get Page</a>
<a href='#' onclick='javascript:GetText();'>Get Contents!</a>
</body>
</html>
I made a script with an image and a javascript function but it doesn't work. It should redirect to www.moseso.de when you click the image. What's wrong with it?
<html>
<head>
<title>Hallo</title>
</head>
<body>
<img src="test.jpg" onclick="func" />
<script>
function func() {
window.location="www.moseso.de"
}
</script>
</body>
</html>
try setting:
onclick="func();"
also close the statement:
window.location="www.moseso.de";
You can try this:
<img src="test.jpg" alt="" class="img.my_clickable_image" />
<script>
$(document).ready(function() {
$('my_clickable_image').click(function() {
window.location.href = www.moseco.de';
});
});
</script>
Im trying to redirect to another html page on load of one page. Below is my code (I want to automatically load 2.html when i open 1.html)
P.S: I could not use window.location.href because of specific use case
1.html
<html>
<head>
<script src="jquery-2.1.1.min.js"></script>
<script type = "text/javascript">
$( document ).ready(function() {
//$("#second")[0].click();
document.getElementById("second").click();
});
</script>
</head>
<body>
<a href = "2.html" id="second"/> click </a>
</body>
</html>
I tried $("#second")[0].click() and document.getElementById("second").click(). Both works fine in desktop browsers. But in android Both doesn't seems to work.
Do we have any ways to achieve it ? Please Help
Use this code.
Solution 1
<script>
function newPage() {
window.location.assign("http://www.adarshkr.com")
}
</script>
Solution 2
<script>
var url = "http://stackoverflow.com";
$(location).attr('href',url);
</script>
Thanks to #mod and #samsad. I resolved it in the following way,
<html>
<head>
<script src="jquery-2.1.1.min.js"></script>
<script type = "text/javascript">
window.onunload = function(){};
$( document ).ready(function() {
history.pushState({}, "", "1.html");
var url = "2.html";
window.location.assign(url);
});
</script>
</head>
<body>
<a href = "2.html" id="second"/> click </a>
</body>
</html>
I'm going sending data the Info page with ..$_get.. but I want when click ..a href=new.php?data=1.. to activate loading and Not all received data loading be enabled and after the completion information inside page new.php , loading deletion and .div id=result. is displayed or show information
new.php
<script type="text/javascript">
$(document).ready(function(){
$('a').click(function(){
$('#result').hide();
$('#main').html('<strong>loading...!</strong>;');
success:function(){
$('#main').html('');
$('#result').show();
}
});
});
</script>
<body>
<div id="main"></div>
test
<div id="result">
<?php
if(isset($_GET['data'])){
echo $_GET['data'];
}
?>
</div>
when click a href= Enable loading then when Information was received, remove loading and put the information in div result displayed
You made a mistake, click() isn't an ajax call so I don't understand why you put a success callback, try to remove it because it made a syntax JS error for sure.
There is the solution :
<script type="text/javascript">
$(document).ready(function(){
$('a').click(function(event){
$('#result').hide();
$('#main').html('<strong>loading...!</strong>;');
});
});
</script>
<body>
<div id="main"></div>
<div id="result">
<?php
if(isset($_GET['data'])){
echo $_GET['data'];
}
?>
</div>
</body>
ok basically i am getting a white page when i try to use the facebook share buttons, both the new and the sharer.php version
i am trying to share a url like the following:
https://www.facebook.com/sharer/sharer.php?u=https://**.com/3e68ec7f58134f66d09a1c05c2783385/index.html
now the page loads fine if i paste in a new browser window, or even when i refresh the white / black page
here is my code:
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body {
overflow:hidden;
}
</style>
<link rel="stylesheet" href="onlinedojo/css/layout.css" type="text/css" media="screen" />
<script src="js/jquery-1.5.2.min.js" type="text/javascript"></script>
<script src="onlinedojo/js/hideshow.js" type="text/javascript"></script>
<script src="onlinedojo/js/jquery.tablesorter.min.js" type="text/javascript"> </script>
<script type="text/javascript" src="onlinedojo/js/jquery.equalHeight.js"></script>
<title>post</title>
</head>
<body>
<div id="fb-root"></div>
<script>
function postToFb(){
window.open('<?php echo $fburl ?>','1317220786706','width=400,height=400,toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');
window.close();
return false;
}
</script>
<form class="submit_link" style="float:right">
<input type="submit" class="alt_btn" value="Share on Facebook" onclick="postToFb();" />
</form>
</body>
</html>
any help would be appreciated - this is driving me crazy!
You don't need a form or submit button here. so just remove form and button and put simple share link and try this
HTML:
<a href="javascript: void(0)" onClick="fbpopup('<?php echo urlencode($fburl); ?>')">
Share on Facebook
</a>
Javascript
<script>
function fbpopup(popwhat) {
window.open( popwhat, "fbshare", "height=380,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0" )
}
</script>
Well, yo try this
<script>
function postToFb(url) {
window.open(url, '_blank', 'width=530,height=460,left=' + (screen.availWidth / 2 - 250) + ',top=' + (screen.availHeight / 2 - 250) + '');
return false;
}
<?php
$title = urlencode('your title');
$summary = urlencode('your sumary');
$url_base = urlencode('url to share');
$url_image = urlencode('thumbnail url');
$url_to_share = "http://www.facebook.com/sharer/sharer.php?s=100&p[title]=$title&p[summary]=$summary&p[url]=$url_base&p[images][0]=$url_image";
?>
postToFb('<?php echo urlencode($url_to_share) ?>') {
</script>
I hope this help you.