When using below code share on Facebook but https://www.facebook.com/dialog/return/close#_=_ does nothing return.
<?php
$social_link = "https://www.google.co.in";
$sharelink = "http://www.facebook.com/sharer.php?u=".urlencode($social_link)."&t=&s=100";
$strWindowFeatures = "location=yes,height=570,width=520,scrollbars=yes,status=yes";
echo "<script>var win = window.open('$sharelink', '_self', '$strWindowFeatures');</script>";
?>
You can create share button using the given tag and add given script in your script section
<a onclick="shareinsocialmedia('https://www.facebook.com/sharer/sharer.php?u=<?php echo $ShareUrl;?>&title=<?php echo $Title;?>')" href=""> <img src="images/facebook.gif" title="share in facebook"> </a>
<script type="text/javascript" async >
function shareinsocialmedia(url){
window.open(url,'sharein','toolbar=0,status=0,width=648,height=395');
return true;
}
</script>
Related
$select_pic = "SELECT pic.photo_link,od.* from orders as od inner join photo as pic ON pic.user_id = od.user_id WHERE od.id = '".$orderid."'";
$pic = $common->select_inner($select_pic);
foreach($pic as $photo){
}
I am getting images from this in $photo['photo_link'];
I want to download picture on click of download button how can i do this using php or javascript.
<a download="<?php echo $photo['photo_link']; ?>" title="ImageName">
<img alt="ImageName" src="uploads/category/<?php echo $photo['photo_link']; ?>">
</a>
I have tried this but its not working
You are missing href attribute in tag.
I have checked with below code working:
<a href="" download="<?php echo $photo['photo_link']; ?>" title="ImageName">
<img alt="ImageName" src="uploads/category/<?php echo $photo['photo_link']; ?>">
</a>
Please see following link for your reference: href image link download on click
Try this code
<a href="uploads/category/<?php echo $photo['photo_link']; ?" download>
<button>Download</button>
</a>
I have two pages: test.php and backend.php.
test.php has three images which when clicked takes the user to backend.php. I want the src of the image clicked to be displayed on backend.php. I am trying to achieve this task via JavaScript and Ajax but the src of the image doesn't appear on backend.php. Code for the same are given below:
test.php:
<?php
session_start();
?>
<html>
<head>
<script src="jquery-1.9.1.js">
</script>
<script>
function clickIt(data){
$.ajax({
url: 'backend.php',
data: {"imgsrc":data},
type: 'post',
success:function(res){
alert(res.message);
}
});
}
</script>
</head>
<body>
<a href="backend.php">
<img onclick="clickIt(this.src)" src="img1.jpg"/>
</a>
<a href="backend.php">
<img onclick="changeIt(this.src)" src="img2.jpg"/>
</a>
<a href="backend.php">
<img onclick="changeIt(this.src)" src="img3.jpg"/>
</a>
</body>
</html>
backend.php:
<?php
session_start();
?>
<?php
echo $_POST['imgsrc'];
echo 'Back';
?>
What am I possibly doing wrong?
Try this;
HTML:
<body>
<a href="javascript:void(0);">
<img onclick="clickIt(this.src)" src="img1.jpg"/>
</a>
<a href="javascript:void(0);">
<img onclick="changeIt(this.src)" src="img2.jpg"/>
</a>
<a href="javascript:void(0);">
<img onclick="changeIt(this.src)" src="img3.jpg"/>
</a>
</body>
Jquery:
function clickIt(data){
window.location.href = 'backend.php?imgsrc='+data; // redirect to backend.php
}
In backend.php
<?php
echo $_GET['imgsrc']; // use $_GET
echo 'Back';
?>
Click event of tag is not firing because tag takes the
page to backend page before tag click event gets fired. You can resolve this problem simply by removing the tag from each line.
You cannot access ajax response as res.message as you haven't echo the response in json format. You can access response simply from res variable
Also change the function name to changeIt to clickIt as you have defined function has clickIt
// use only res
success:function(res)
{
alert(res);
}
<img onclick="clickIt(this.src)" src="img1.jpg"/>
<img onclick="clikcIt(this.src)" src="img2.jpg"/>
<img onclick="clickIt(this.src)" src="img3.jpg"/>
This is my Current Code in my wordpress:
<div class="entry-content">
<a href="<?php
echo $currenturl.'?material=&type='.$get_type;
?>">All Materials</a>
<?php
$materials = get_field('materials',$valueid);
foreach($materials as $id):?>
<a href="<?php
$matterm = get_term($id,'materials');
$matslug = $matterm->slug;
$mattitle = $matterm->name;
echo $currenturl."?material=".$matslug.'&type='.$get_type;
?>"><?php
echo $mattitle;
?>
</a>
<?php endforeach; ?>
</div>
This is the Current Output:
<div class="entry-content">
<a href="#>Material 1</a>
<a href="#>Material 1</a>
</div>
And I want the output of the code will be:
<div class="entry-content">
<a class="current" href="#>Material 1</a>
<a href="#>Material 1</a>
</div>
and I have this Script on my header but it will not function:
<script type="text/javascript">
window.onload = function() {
document.getElementById('entry').className = 'current';
};
</script>
You're mixing up class and id (or just left off the id). If you do console.log(getElementById("entry")), I bet you get back null.
I think you have to replace this.
window.onload = function() {
var parentDiv = document.getElementsByClassName('entry-content');
parentDiv.childNodes[0].className = 'current';
};
In your code:
document.getElementById('entry').className = 'current';
getElementById(ID) it's a javascript method and used for getting the element with the specific ID
And your HTML is not correct, you forgot the end " of href.
You should write your HTML like -
<div class="entry-content">
<a id="entry" href="#">Material 1</a>
Material 1
</div>
After make above changes, your code works perfectly. See Demo
I found the answer how to open few pages in new tabs with a single click, but I don't know how to place urls from mysqli database using fetch.
mysqli statement is ...
$pick_site = $mysqli->prepare("SELECT url FROM sites where chosen = ? ORDER BY name ASC");
$pick_site->bind_param('s', $yesterday);
$pick_site->execute();
$pick_site->store_result();
$pick_site->bind_result($list_sites);
while ($pick_site->fetch_array()) {
$mysites = $list_sites;
}
here is working javascript code for opening tabs
<a id="test" href="#"> CLick </a>
<script type="text/javascript">
document.getElementById("test").onclick = function(){
window.open("http://www.google.com",'_blank');
window.open("http://www.p3php.in",'_blank');
}
</script>
Thank you very much,
Ivan.
Just echo links like that :
<a id="test" href="#"> CLick </a>
<script type="text/javascript">
document.getElementById("test").onclick = function(){
<?php while ($pick_site->fetch_array()) { ?>
window.open("<?= $link ?>",'_blank');
<?php } ?>
}
</script>
I would like to ask about the Button with Roll Over Javascript I have in my wordpress theme, the problem is the code is divided in two parts:
The 1st code is about Javascript
<script>
<!--
if(document.images)
{
var image_array = new Array();
// path to the directory with images
var path = '/img/';
// enumeration of the "active" images
image_array[0] = "<?php bloginfo('template_directory'); ?>/button1_red.png";
image_array[1] = "<?php bloginfo('template_directory'); ?>/button2_red.png";
image_array[2] = "<?php bloginfo('template_directory'); ?>/button3_red.png";
var preload_image = new Array ();
for(var i=0; i<image_array.length; i++)
{
preload_image[i]= new Image();
preload_image[i].src = image_array[i];
}
}
function rollover(name, filename)
{
var fullpath = '' + filename;
document.images[name].src = fullpath;
}
//-->
</script>
<!--ROLL OVER SCRIPT-->
and the 2nd is html.
<div id="buttons">
<a href="http://twitter.com/bendaggers" target="_blank" onmouseover=rollover('button2','<?php bloginfo('template_directory'); ?>/button2_red.png'); onmouseout=rollover('button2','<?php bloginfo('template_directory'); ?>/button2_blue.PNG')><img src="<?php bloginfo('template_directory'); ?>/button2_blue.PNG" name="button2" width="35" height="35" border="0" title="Follow us on Twitter!" alt="BenDaggers.com: Follow us on Twitter!"/></a>
<a href="http://feeds.feedburner.com/bendaggers" target="_blank" onmouseover=rollover('button3','<?php bloginfo('template_directory'); ?>/button3_red.png'); onmouseout=rollover('button3','<?php bloginfo('template_directory'); ?>/button3_blue.PNG')><img src="<?php bloginfo('template_directory'); ?>/button3_blue.PNG" name="button3" width="35" height="35" border="0" title="Subscribe to our RSS Feeds!" alt="BenDaggers.com: Subscribe to our RSS Feeds!" /></a>
</div>
Where should i put the javascript code since the Button should be in sidebar (sidebar.php)?
I tried putting the javascript in the index.php and the html code in sidebar.php but its not working.
Any help?
Put the HTML in sidebar.php and javascript in header.php (assuming your theme has a header.php file) inside the <head> tag.
Because your html part depends on the Javascript part, the Javascript part must go first in the page. The simplest way to ensure this without knowing much about the structure of Wordpress is simply include both snippets in the same place, say sidebar.php, one after the other.