在我的扩展中,我创建一个选项卡,并results.html从名为 的后台脚本打开一个在其中命名的 html 文件background.js。创建选项卡后,我将注入一个名为results.js该新创建的选项卡的 JavaScript 文件。
但它在我的控制台中抛出以下错误background.js:
Unchecked runtime.lastError: Cannot access contents of url "chrome-extension://hcffonddipongohnggcbmlmfkeaepfcm/results.html".
Extension manifest must request permission to access this host.
Run Code Online (Sandbox Code Playgroud)
浏览其他 stackoverflow 问题的解决方案时,我尝试在以下位置添加以下权限manifest.json:
<all_urls>chrome-extension://*抛出错误:权限“chrome-extension://*”未知或 URL 模式格式错误。但以上都不起作用。
此外,results.js注入后应该发送消息以background.js获取响应一些数据以供输入results.html。
我的代码:
清单.json
{
"manifest_version":2,
"name":"Extension Name",
"description":"This is description of extension.",
"version":"1.0.0",
"icons":{"128":"icon_128.png"},
"browser_action":{
"default_icon":"icon.png",
"default_popup":"popup.html"
},
"permissions":["activeTab", "background", "tabs", "http://*/*", "https://*/*","<all_urls>"],
"background": {
"scripts": ["background.js"],
"persistent": false
},
"web_accessible_resources": …Run Code Online (Sandbox Code Playgroud) 我想将我的 selenium chrome Web 驱动程序启动到当前现有会话。
因此,我尝试通过远程调试进行连接,而不是启动新实例。
所以我所做的是通过cmd在127.0.0.1:6813启动chrome。
C:\Program Files (x86)\Google\Chrome\Application>chrome.exe '127.0.0.1:6813'
Run Code Online (Sandbox Code Playgroud)
一个新的 chrome 实例启动了。
现在,在我的代码中,我使用 chrome 选项添加了 debugger_address="127.0.0.1:6813" 。
chrome_options.debugger_address="127.0.0.1:6813"
Run Code Online (Sandbox Code Playgroud)
但我的 Spyder IDE 出现以下错误:
runfile('C:/Users/Gupta Niwas/Downloads/Programming/Projects/Mi/temp7.py', wdir='C:/Users/Gupta Niwas/Downloads/Programming/Projects/Mi')
Traceback (most recent call last):
File "<ipython-input-9-77e28441ef9f>", line 1, in <module>
runfile('C:/Users/Gupta Niwas/Downloads/Programming/Projects/Mi/temp7.py', wdir='C:/Users/Gupta Niwas/Downloads/Programming/Projects/Mi')
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
execfile(filename, namespace)
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/Gupta Niwas/Downloads/Programming/Projects/Mi/temp7.py", line 22, in <module>
browser = webdriver.Chrome(chrome_options=chrome_options,executable_path=cpath)
File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 75, in __init__
desired_capabilities=desired_capabilities)
File …Run Code Online (Sandbox Code Playgroud) 我正在尝试为产品目录创建模态结构。每当用户单击产品名称时就会出现模态框。
默认情况下modal class有display="none"
通过调用函数来style.display="visible";执行onclickshow(id);
单击时close(X) icon hide(id);被调用但style.display="none";没有任何效果并且模式不会隐藏。
请仅用简单的 JavaScript 回答。
代码: https: //jsfiddle.net/abhaygc/zymkv1wq/
代码片段:
function show(id) {
var modal = document.getElementById(id);
modal.style.display="block";
}
function hide(id){
var close = document.getElementById(id);
console.log("It's here.");
close.style.display="none";
}Run Code Online (Sandbox Code Playgroud)
body{
height: 100vh;
margin: 0px;
overflow-y: scroll;
}
.header{
background-color: white;
height:8%;
overflow: hidden;
font-style: "Roboto";
font-size: 25px;
border-bottom: 2px solid;
border-bottom-color: #cccccc;
}
#clear{
clear: both;
}
.logo{
margin-top: 12px;
float: left;
left: 0px;
padding-right: …Run Code Online (Sandbox Code Playgroud)我正在尝试具有以下一般布局层次结构 ConstraintLayout>CardView>ConstraintLayout>Button 的布局。
第二个constraintLayout 必须贴在cardView 的右下角。
但是卡片视图中的约束不起作用。
我首先尝试用 LinearLayout 替换 2nd ConstraintLayout 但它也没有帮助。约束对他们没有影响。
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".home_fragment"
android:id="@+id/home_fragment">
<android.support.v7.widget.CardView
android:id="@+id/first_card"
android:layout_width="200dp"
android:layout_height="100dp"
app:cardBackgroundColor="@color/card_color"
app:cardCornerRadius="15dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginTop="200dp"
>
<android.support.constraint.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 1 "
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/second_card"
android:layout_width="200dp"
android:layout_height="100dp"
android:layout_marginTop="56dp"
app:cardBackgroundColor="@color/card_color"
app:cardCornerRadius="20dp"
app:layout_constraintStart_toStartOf="@id/first_card"
app:layout_constraintTop_toBottomOf="@id/first_card">
<android.support.constraint.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 2 "
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
</android.support.constraint.ConstraintLayout> …Run Code Online (Sandbox Code Playgroud) android android-button android-studio android-cardview android-constraintlayout
javascript ×2
android ×1
automation ×1
css ×1
display ×1
html ×1
modal-dialog ×1
python-3.x ×1
selenium ×1
spyder ×1