我正在尝试在网页上实现复制到剪贴板按钮。下面是我写的代码
function copyToClipboard(element) {
var $temp = $("<input>");
$("body").append($temp);
$temp.val($(element).text()).select();
document.execCommand("copy");
$temp.remove();
}Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
</script>
<p id="p1">Text1</p>
<p id="p2">Text2</p>
<button onclick="copyToClipboard('#p1')">Copy Text1</button>
<button onclick="copyToClipboard('#p2')">Copy Text2</button>
<br/><br/>
<input type="text" placeholder="Paste here for test" /> Run Code Online (Sandbox Code Playgroud)
但是,这似乎不适用于IE 9、11和Safari。是否有任何更改/替代实现我可以用来在我的网页上实现它。
我的PHP文件中的SQL查询是
SELECT start_time,end_time FROM data;
Run Code Online (Sandbox Code Playgroud)
这将返回两个不同列中的两个varchar字段.现在我想结合这些.所以我试过了
Select start_time+' '+end_time as time from data;
Run Code Online (Sandbox Code Playgroud)
这会返回一些数值.所以我尝试过:
Select cast(start_time+' '+end_time) as time from data;
Run Code Online (Sandbox Code Playgroud)
如果我表中的数据是start_time =上午8:00 = end_time = 9:30 am
我怎样才能显示上午8:00 - 上午9:30
我正在使用Selenium来测试电子商务应用程序.我需要检查在列表页面上选择类别时列出的项目是否与数据库中的项目匹配.所以我使用selenium访问页面并将页面源存储在文本文件中.我稍后使用HTMLCleaner和JSoup解析此文本文件以获取我希望用DB验证的字段.
但是,我注意到页面上列出的某些产品使用特殊字符,如™,®等,这些字符未正确存储/检索并显示为问号.
我用来存储页面源代码:
BufferedWriter writer = null;
try
{
writer = new BufferedWriter(new FileWriter(filepath+"/"+filename+".txt"));
writer.write(driver.getPageSource());
}
catch ( IOException e)
{
e.printStackTrace();
}
finally
{
try
{
writer.close( );
}
catch (IOException e)
{
}
}
Run Code Online (Sandbox Code Playgroud)
检索和解析文件
Document htmlFile = Jsoup.parse(fileSavedPreviously,"ISO-8859-1");
TagNode tagNode = new HtmlCleaner().clean(fileSavedPreviously);
try {
org.w3c.dom.Document doc = new DomSerializer(new CleanerProperties())
.createDOM(tagNode);
} catch (ParserConfigurationException e) {
e.printStackTrace();
}
//rest of the parsing....
Run Code Online (Sandbox Code Playgroud) 我正在尝试为 Android 应用程序编写浓缩咖啡测试,并且需要知道如何自动化使用AutoCompleteTextView的部分。我的应用程序使用的代码如下:
活动主文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="15dp"
android:text="Name a fruit from (Apple Banana Cherry Date Grape Kiwi Mango Pear)" />
<AutoCompleteTextView
android:id="@+id/autoCompleteTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView"
android:layout_marginLeft="36dp"
android:layout_marginTop="17dp"
android:ems="10"
android:text="">
<requestFocus />
</AutoCompleteTextView>
Run Code Online (Sandbox Code Playgroud)
MainActivity.java
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
public class MainActivity extends Activity {
String[] fruits = {"Apple", "Apples2", "Apples3", "Date", "Grape", "Kiwi", "Mango", "Pear"};
@Override
protected void onCreate(Bundle …Run Code Online (Sandbox Code Playgroud)