What does the following code mean -
<a href="javacsript:;" onClick="addItem(160)">some link</a>
My basic doubt is which script is run when we click on the link
Hello,
I am trying with no success to modify the code example from:
http://www.inter-fuser.com/2009/08/android-animations-3d-flip.html
so it will rotate the images in a loop, when clicking on the image once. (second click should pause).
I tried using Handler and threading but cannot update the view since only the main thread can update UI.
Exception I get from the code below:
android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
[in 'image1.startAnimation(rotation);' ('applyRotation(0, 90);' from the main thread)]
package com.example.flip3d;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.widget.ImageView;
public class Flip3d extends Activity {
private ImageView image1;
private ImageView image2;
private boolean isFirstImage = true;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
image1 = (ImageView) findViewById(R.id.image01);
image2 = (ImageView) findViewById(R.id.image02);
image2.setVisibility(View.GONE);
image1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if (isFirstImage) {
applyRotation(0, 90);
isFirstImage = !isFirstImage;
} else {
applyRotation(0, -90);
isFirstImage = !isFirstImage;
}
}
});
}
private void applyRotation(float start, float end) {
// Find the center of image
final float centerX = image1.getWidth() / 2.0f;
final float centerY = image1.getHeight() / 2.0f;
// Create a new 3D rotation with the supplied parameter
// The animation listener is used to trigger the next animation
final Flip3dAnimation rotation =
new Flip3dAnimation(start, end, centerX, centerY);
rotation.setDuration(500);
rotation.setFillAfter(true);
rotation.setInterpolator(new AccelerateInterpolator());
rotation.setAnimationListener(new DisplayNextView(isFirstImage, image1, image2));
if (isFirstImage)
{
image1.startAnimation(rotation);
} else {
image2.startAnimation(rotation);
}
}
}
How can I manage to update the UI and control the rotation within onClick listener?
Thank you,
Oakist
I can not get the form to submit with the button. The best luck I have had is to send a generic email with no data attached.
This is the code:
<input name="mailto: [email protected]" type="submit" onClick=mailto: [email protected] value="Submit Form" id="mailto: [email protected]" >
the value is: /frms/contact.con
Can anyone help????
pbutton.setOnClickListener(new OnClickListener()
{ private AlertDialog show;
public void onClick(View arg0)
{
if ((input1.getText().length() == 0) || (input1.getText().toString().equals(" ")) || (input2.getText().length() == 0) || (input2.getText().toString().equals(" "))|| (input1.getText().toString().equals(""))||(input2.getText().toString().equals("")))
{
show = new AlertDialog.Builder(MainActivity.this).setTitle("Error").setMessage("Some inputs are empty").setPositiveButton("OK", null).show();
}
double result = new Double(input1.getText().toString())+ new Double(input2.getText().toString());
output.setText(Double.toString(result));
}
I've also tried passing the context which also doesn't work
So two questions here: If I use <input type="button" onclick="validate()"> then the enter key wouldn't work. However, I can use type="submit" but how would I invoke validate()?
Hey, I have the following function on an onClick call:
function addComment() {
jQuery.noConflict()
jQuery('head').append('<link rel="stylesheet" media="screen" type="text/css" href="colorbox/colorbox-images.css" />'); //this doesn't add correctly.
jQuery.fn.colorbox({inline:false, href:'boxes/add-comment.html'});
return false;
};
However, the STYLESHEET append line doesn't seem to initialise properly. Screenshots below:
this code generates problem [encountered problem of window] and close all the safari windows,
but this code is working fine with Internet Explorer. What will I do ?
have any alternative method for closing current opened window in every browser.
<input type='button' value='close' onclick='window.close()'>
Setting value in html control in code behind without making server control
<input type="text" name="txt" />
<%--Pleas note I don't want put runat=server here to get the control in code behind--%>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
Code behind
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
//If I want to initlize some value in input, how can I set here
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Request["txt"] // Here I am getting the value of input
}
Thanks
I have created an App Widget for Android 1.5. It uses a TextView to present a number of individual Text Links using ClickableSpans. However, the onClick event handler on the ClickableSpan is never called, it appears that you can not select individual components on the widget just the whole widget.
This approach works fine for a normal app, so what I do I need to change to make this work for a widget?
How does one draw text (with onClick event) in a caption bar on vista with aero Like Windows 7 ?
The example at delphi.about.com doesn't work on Vista with aero. Do you have any ideas?
Thanks to all.
Sorry for my bad english.
I'm using jQuery's addClass to add a class to an tab so when clicked it'll change the class so it's obvious the tab is highlighted.
My HTML
<div id="mainNav">
<ul>
<li id="LinktheBand" onclick="nav('theBand')">The Band</li>
<li id="linkTheMusic" onclick="nav('theMusic')">The Music</li>
My CSS
#mainNav li {
float:left;
margin-right:5px;
color:white;
font-family:Tahoma;
font-weight:bold;
padding: 10px 8px 0px 8px;
background:url('../images/transparent-65.png');
height:40px;
height: 25px !important;
border:1px solid #000;
}
#mainNav li:hover {
float:left;
margin-right:5px;
color:white;
font-family:Tahoma;
font-weight:bold;
padding: 10px 8px 0px 8px;
background: #660000;
height:40px;
height: 25px !important;
border:1px solid #660000;
}
.mainNavSelected {
float:left;
margin-right:5px;
color:white;
font-family:Tahoma;
font-weight:bold;
padding: 10px 8px 0px 8px;
background: #660000;
height:40px;
height: 25px !important;
border:1px solid #660000;
}
My Javascript
function nav(a) {
$('#'+a).show();
$('#Link'+a).addClass('mainNavSelected');
}
This works properly, I check firebug and can see the class="mainNavSelected" is added, but the list element doesn't take any properties of the new class. Firebug lists all the class items for mainNavSelected, but has them all crossed out. What am i missing to replace the class of this element?
Hi
I been finding that for something that I consider pretty import there is very little information or libraries on how to deal with this problem.
I found this while searching. I really don't know all the million ways that a hacker could try to insert the dangerous tags.
I have a rich html editor so I need to keep non dangerous tags but strip out bad ones.
So is this script missing anything?
It uses html agility pack.
public string ScrubHTML(string html)
{
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(html);
//Remove potentially harmful elements
HtmlNodeCollection nc = doc.DocumentNode.SelectNodes("//script|//link|//iframe|//frameset|//frame|//applet|//object|//embed");
if (nc != null)
{
foreach (HtmlNode node in nc)
{
node.ParentNode.RemoveChild(node, false);
}
}
//remove hrefs to java/j/vbscript URLs
nc = doc.DocumentNode.SelectNodes("//a[starts-with(translate(@href, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'javascript')]|//a[starts-with(translate(@href, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'jscript')]|//a[starts-with(translate(@href, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'vbscript')]");
if (nc != null)
{
foreach (HtmlNode node in nc)
{
node.SetAttributeValue("href", "#");
}
}
//remove img with refs to java/j/vbscript URLs
nc = doc.DocumentNode.SelectNodes("//img[starts-with(translate(@src, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'javascript')]|//img[starts-with(translate(@src, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'jscript')]|//img[starts-with(translate(@src, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'vbscript')]");
if (nc != null)
{
foreach (HtmlNode node in nc)
{
node.SetAttributeValue("src", "#");
}
}
//remove on<Event> handlers from all tags
nc = doc.DocumentNode.SelectNodes("//*[@onclick or @onmouseover or @onfocus or @onblur or @onmouseout or @ondoubleclick or @onload or @onunload]");
if (nc != null)
{
foreach (HtmlNode node in nc)
{
node.Attributes.Remove("onFocus");
node.Attributes.Remove("onBlur");
node.Attributes.Remove("onClick");
node.Attributes.Remove("onMouseOver");
node.Attributes.Remove("onMouseOut");
node.Attributes.Remove("onDoubleClick");
node.Attributes.Remove("onLoad");
node.Attributes.Remove("onUnload");
}
}
// remove any style attributes that contain the word expression (IE evaluates this as script)
nc = doc.DocumentNode.SelectNodes("//*[contains(translate(@style, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'expression')]");
if (nc != null)
{
foreach (HtmlNode node in nc)
{
node.Attributes.Remove("stYle");
}
}
return doc.DocumentNode.WriteTo();
}
If the script tag is above or below the body in a HTML page, does it matter for the performance of a website?
And what if used in between like this:
<body>
..blah..blah..
<script language="JavaScript" src="JS_File_100_KiloBytes">
function f1() {
.. some logic reqd. for manipulating contents in a webpage
}
</script>
... some text here too ...
</body>
Or is this better?:
<script language="JavaScript" src="JS_File_100_KiloBytes">
function f1() {
.. some logic reqd. for manipulating contents in a webpage
}
</script>
<body>
..blah..blah..
..call above functions on some events like onclick,onfocus,etc..
</body>
Or this one?:
<body>
..blah..blah..
..call above functions on some events like onclick,onfocus,etc..
<script language="JavaScript" src="JS_File_100_KiloBytes">
function f1() {
.. some logic reqd. for manipulating contents in a webpage
}
</script>
</body>
Need not tell everything is again in the <html> tag!!
How does it affect performance of webpage while loading? Does it really?
Which one is the best, either out of these 3 or some other which you know?
And one more thing, I googled a bit on this, from which I went here: Best Practices for Speeding Up Your Web Site and it suggests put scripts at the bottom, but traditionally many people put it in <head> tag which is above the <body> tag. I know it's NOT a rule but many prefer it that way. If you don't believe it, just view source of this page! And tell me what's the better style for best performance.
I want to receive notifications whenever links are clicked or text fields are changed in a Webkit instance in Qt. How can I hook up event listeners to a QWebElement?
I know I can put some Javascript on each element’s onchange / onclick handler, but I’m looking for a cleaner solution.
How can i add a link to my td tag from a table?
onclick doesnt work for me :S, or maybe a good example :P
my td tag:
$world .= ('<td background="images/world/Heli.jpg" border="1"></td>');
link:
<a href="?site=world&action=showvillage&id=' . getVillageID(($xm2), ($ym2)) . '"></a>
thnx :D
How can i reset a display:none and add some value here is the code
onclick="$('reason{$test->id}').css('display:block');
$('#reasonid{$test->id}').val(this.value);"
I been finding that for something that I consider pretty import there is very little information or libraries on how to deal with this problem.
I found this while searching. I really don't know all the million ways that a hacker could try to insert the dangerous tags.
I have a rich html editor so I need to keep non dangerous tags but strip out bad ones.
So is this script missing anything?
It uses html agility pack.
public string ScrubHTML(string html)
{
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(html);
//Remove potentially harmful elements
HtmlNodeCollection nc = doc.DocumentNode.SelectNodes("//script|//link|//iframe|//frameset|//frame|//applet|//object|//embed");
if (nc != null)
{
foreach (HtmlNode node in nc)
{
node.ParentNode.RemoveChild(node, false);
}
}
//remove hrefs to java/j/vbscript URLs
nc = doc.DocumentNode.SelectNodes("//a[starts-with(translate(@href, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'javascript')]|//a[starts-with(translate(@href, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'jscript')]|//a[starts-with(translate(@href, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'vbscript')]");
if (nc != null)
{
foreach (HtmlNode node in nc)
{
node.SetAttributeValue("href", "#");
}
}
//remove img with refs to java/j/vbscript URLs
nc = doc.DocumentNode.SelectNodes("//img[starts-with(translate(@src, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'javascript')]|//img[starts-with(translate(@src, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'jscript')]|//img[starts-with(translate(@src, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'vbscript')]");
if (nc != null)
{
foreach (HtmlNode node in nc)
{
node.SetAttributeValue("src", "#");
}
}
//remove on<Event> handlers from all tags
nc = doc.DocumentNode.SelectNodes("//*[@onclick or @onmouseover or @onfocus or @onblur or @onmouseout or @ondoubleclick or @onload or @onunload]");
if (nc != null)
{
foreach (HtmlNode node in nc)
{
node.Attributes.Remove("onFocus");
node.Attributes.Remove("onBlur");
node.Attributes.Remove("onClick");
node.Attributes.Remove("onMouseOver");
node.Attributes.Remove("onMouseOut");
node.Attributes.Remove("onDoubleClick");
node.Attributes.Remove("onLoad");
node.Attributes.Remove("onUnload");
}
}
// remove any style attributes that contain the word expression (IE evaluates this as script)
nc = doc.DocumentNode.SelectNodes("//*[contains(translate(@style, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'expression')]");
if (nc != null)
{
foreach (HtmlNode node in nc)
{
node.Attributes.Remove("stYle");
}
}
return doc.DocumentNode.WriteTo();
}
I'm iteration over records and want to create the toggle-options for records but I can't replace the div-id with the records:
<% for bill in @bills %
<% tmp = "test"%
<%= link_to '» now','#', :onclick = '$("#{tmp}").toggle();' %
Instead of getting:
» now
I'm getting:
» now
So he isn't evaluation the ruby variable in the string. How can I do this?
Thanks for your help and I'm new in jquerry.
I am new to Javascript. I am facing a problem with global variables. I can't figure out that why the global variables are not working as the code looks ok. Please Help me solve this problem.
I will breifly explain the code first.I have some text on a page which changes to text field when clicked. When I define the variables inside the functions body the code starts working fine. When these variables are defined globally as in the following code, the console displays this error: the variable is not defined. Here my code:
<!DOCTYPE HTML>
<html>
<head>
<title>Span to Text Box - Demo - DOM</title>
<script type="text/javascript" language="javascript">
var textNode = document.getElementById('text');
var textValue = textNode.firstChild.nodeValue;
var textboxNode = document.getElementById('textbox');
var doneButton = document.getElementById('done');
function change()
{
textboxNode.setAttribute('value', textValue);
textNode.style.display = 'none';
textboxNode.setAttribute('type','text');
doneButton.setAttribute('type','button');
}
function changeBack()
{
textNode.firstChild.nodeValue = textboxNode.value;
textNode.style.display = 'block';
textboxNode.setAttribute('type', 'hidden');
doneButton.setAttribute('type','hidden');
}
</script>
</head>
<body>
<p id="text" onClick="change()">Click me!</p>
<form onSubmit="return false;">
<input type="hidden" id="textbox" />
<input type="hidden" id="done" onClick="changeBack()" value="Done" />
</form>
</body>
</html>
Please Help!
Thanks in Advance.
I've designed a training program and Html texts and image put into training.
I want to address my html file by an activity to sent another activity.
This is MainActivity
/*
* ListView item click listener. So we'll have the do stuff on click of
* our ListItem
*/
listViewArticles.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
switch (position) {
case 0:
Intent newActivity0 = new Intent(TrickPage.this,a_Dotted_Lines.class);
startActivity(newActivity0);
break;
case 1:
Intent newActivity1 = new Intent(TrickPage.this,TutorialsPage.class);
startActivity(newActivity1);
break;
case 2:
Intent newActivity2 = new Intent(TrickPage.this,TutorialsPage.class);
startActivity(newActivity2);
break;
case 3:
Intent newActivity3 = new Intent(TrickPage.this,TutorialsPage.class);
startActivity(newActivity3);
break;
default:
// Nothing do!
}
and this SecondActivity (show WebView)
public class a_Dotted_Lines extends Activity {
private WebView webView;
@SuppressLint("SetJavaScriptEnabled")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.a_dotted_lines);
// Button HOME
ImageButton ImageButton_home = (ImageButton) findViewById(R.id.ImageButton_home);
ImageButton_home.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setClass(a_Dotted_Lines.this, Main.class);
startActivity(intent);
overridePendingTransition(R.anim.fadein, R.anim.fadeout);
}
});
//Button Previous
ImageButton ImageButton_previus = (ImageButton)
findViewById(R.id.ImageButton_previus);
ImageButton_previus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Closing SecondScreen Activity
finish();
}
});
webView = (WebView) findViewById(R.id.webview_compontent);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("file:///android_asset/html/article.htm");
}
}
I want Send "file:///android_asset/html/article.htm" or other addres from MainActivity
Is it possible?
Sorry My English is not good
Consider i have an anchor which looks like this
<a href="~/Resumes/Resumes1271354404687.docx">
~/Resumes/Resumes1271354404687.docx
</a>
I want to get either href/text in jquery onclick of that anchor ...
Is it possible to open the next panel in a jquery accordion menu through a seperate button onclick event? That is instead of clicking the heading to open another panel, use a button not connected to the accordion.
I set up the "Dungeons" InAppBilling example locally and I am ready to try it out, but I am a bit confused. I have a button like this:
Button donate = (Button)findViewById(R.id.donate);
donate.setOnClickListener(new Button.OnClickListener()
{
public void onClick(View v)
{
// But what do I do here? :)
}
});
And when it is called, what do I need to do to actually go to the pay screen on android store?
Thanks!