How to follow on Twitter to enable a button - javascript

I have the following code which seems to be not working.
I want button 2 to enable itself right after the follow click on twitter as well as closing the twitter pop up page.
How can I do it and what's wrong with my current code for enabling button 2?
Thanks ahead,
Appsboss7
Code:
<html>
<head>
<script>
function enableButton2() {
document.getElementById("button2").disabled = false;
}
</script>
</head>
<body>
Follow #BlackShellMedia
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<input type="button" id="button2" value="button 2" disabled />
<script>
$( document ).ready(function() {
$( '#BlackShellMedia' ).click(function() {
enablebutton2();
});
});
</script>
</body>
</html>

Related

Trigger click of an element on the basis of a button using JavaScript code in HTML markup and/or attribute(s)

I want to trigger click on an icon(image) with specific class/id using onclick (or using any other way) of another button. Please see image for reference. Clicking "1" should trigger "2". Currently I am calling a javascript function "launchTopWM" which use following code to trigger click:
$(".custom_toggle_menu_default").trigger("click");
But i am wondering if i can call this code or perform this fucntionality using its click etc, something like href='javascript:$(".custom_toggle_menu_default").trigger("click");'
Following is the Code:
HTML 1:
<img class="custom_toggle_menu_default" src="cc/tt/uu/images/launchTopWM.png">
HTML 2:
<a id="tsp" class="sp" href="launchTopWM()">CNw</a>
Give an id to the element and show the second anchor through pure javascript.
<!DOCTPE html>
<html>
<head>
<title> Button style </title>
<style>
</style>
</head>
<body>
<a href="javascript:void(0)" onclick="getElementById('button').click()" > click me </a>
<button id="button"> Buton </button>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$('#button').click(function(){
alert('Buttons has been clicked');
});
</script>
</body>
</html>
Trigger example, Hope it will give you the idea
<html lang="en">
<head>
<meta charset="utf-8">
<title>Triggger</title>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<button id="tiggerCall">Trigger Focus</button>
<input type="text" placeholder="Onclick Call Focus" value=''>
<script>
$( "#tiggerCall" ).click(function() {
$( "input" ).trigger( "focus" );
});
$( "input" ).focus(function() {
$( "<span>Text box clicked</span>" ).appendTo( "body" ).fadeOut( 1000 );
});
</script>
</body>
</html>

JQuery trigger click event not working

I'm having trouble getting the following to work:
$('#elem').trigger('click');
When I run it, it doesn't trigger a click but it doesn't show any error logs in the console either.
I've also tried the following with no luck:
$('#elem')[0].click();
Any ideas as to what could be going wrong or a solution for this?
Update: Jquery is working and when I inspect the element, #elem does appear (it's an id for a button)
HTML:
<a:button id="elem">My Button</Button>
JQuery:
P.when('A', 'jQuery').execute(function (A, $) {
//when this function is called, it should trigger a button click
triggerButtonClick = function() {
$('#elem').trigger('click');
};
});
Try it in document.ready function, then all dom loads when the document is ready.You can do something like this based on your requirement.
$( document ).ready(function() {
$('#radio').click(function(){
$('#elem')[0].click();
})
});
i have tried this code and it works
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"> </script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("chk1").click(function(){
$('#usr').trigger('click');
});
});
</script>
</head>
<body>
<form action="sample.php">
<button id="chk1">click</button>
<input class="form-control" type="submit" id="usr">
</form>
</body>
</html>
this code works for me:
$(window).load(function() {
$('#menu_toggle').trigger('click');
});
$(document).ready(function () {
$('#elem').click(function () {
alert('clicked');
$(this).css('color', 'red');
});
$('#elem').trigger('click');
});
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<body>
<div id="elem" >test</div>
</body>
</html>

how to click on textarea to activate them with javascript

I want activate textarea like on facebook wall. I was tried .focus() but not working. Is there any way to click on it with javascript or visualbasic ?
check this example:
$( document ).ready(function() {
$("#text_area_id").focus();
});
JSfiddle
<html>
<head>
<script>
window.onload = function() {
document.getElementById("textArea").focus();
};
</script>
</head>
<body>
<form>
<input type="textarea" id="textArea">
</form>
<body>
</html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script language='javascript'>
$( document ).ready(function() {
$("#result").html("Click Now");
$('#tarea').focus(function(){
$("#result").html("Textarea Clicked");
});
});
</script>
<body>
<textarea rows="4" cols="50" id='tarea'></textarea>
<p id='result'></p>
</body>
</html>
document.getElementById('textAreaId').focus(); should work.
If you want the textarea to be focused when the page loads you could add an autofocus attribute to the html element as well

jquery javascript this function is not calling

I have this java script function:
function copyToClipboardCrossbrowser2(text) {
alert(text);
$('#Button1').zclip({
path: '/js/ZeroClipboard.swf',
copy: text
});
}
when I make path: js/ZeroClipboard.swf , google chrome tells me that this file is not exist. but when I put the / it doesn't tell me that it is not working. so the swf is installed.
the alter is printing the correct value. but the copy is not working.
why please?
I already include these:
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/jquery.zclip.js"></script>
Note
In another project, I am working with this library, which means my flash player is working
This is the html of the button that has the id Button
<button type="button" id="Button1" class="copyToBtn" onclick="copyToClipboardCrossbrowser2('00971509396782',this);" title="Copy">
Copy Phone Number</button>
I am working asp.net
and this is the code of the button
<button type="button" id="Button1" class="copyToBtn" type="button" onclick="copyToClipboardCrossbrowser2('<%#Eval("Telephone")%>',this);"
title="Copy">
Copy Phone Number</button>
The id is not changing that is why I gave you the html
js fiddle:
http://jsfiddle.net/6HPuC/
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/zclip/1.1.2/jquery.zclip.min.js"></script>
<title>Test</title>
</head>
<script>
$(function() {
$("#Button1").zclip({
path: 'http://cdnjs.cloudflare.com/ajax/libs/zclip/1.1.2/ZeroClipboard.swf',
copy: function() {
return $(this).data("copy");
}
});
});
</script>
</head>
<body>
<button type="button" data-copy="<%#Eval('Telephone')%>" id="Button1" class="copyToBtn" title="Copy">Copy Phone Number</button>
</body>
</html>
In your code you have used on button click event to bind zClip with button which is Wrong.
When you attach ZClip to button it will automatically handles OnClick event, no need to write on button event
Below is your modified code
<script type="text/javascript">
$(document).ready(function () {
$('#Button1').zclip({
path: '/js/ZeroClipboard.swf',
copy: $('#Button1').attr('data-copy')
});
});
</script>
And button event will be as below:
<button type="button" id="Button1" class="copyToBtn" data-copy="<%#Eval('Telephone')%>" title="Copy">
Copy Phone Number</button>

Replace the current content of div with another page response

Sample code:
<html>
<head>
.....
</head>
<body>
<div id="content">
<form>
....
<input type="submit" onclick="loadAnotherPage()"/>
</form>
</div>
</body>
</html>
I want to load another page say edit_profile.php in the content div. How can it be achieved without refreshing the page?
I tried to use jQuery load() method. But looks like I missed something. Any help would be highly appreciated.
When you click submit button it's submit form and page refresh that's why its not working.
Instead of type submit set button and then set function onclick.
function loadAnotherPage(){
$("#content").load('edit_profile.php');
}
$(document).ready(
function() {
$('#load_file').click(
$.post('edit_profile.php',
{},
function(data){
$("#content").html(data);
},''
)
);
}
);
Try this
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
</head>
<body>
<div id="content"></div>
<button id="loadpage">load new page</button>
<script>
$(document).ready(function () {
$("#loadpage").click(function() {
$.get("edit_profile.php", function(response){
$("#content").html(response);
});
})
});
</script>
</body>
</html>

Categories

Resources