这是一个具体情况: 访问http://new.cloudfile.co/transfer 单击橙色" +"按钮。然后使用javascript: 我想将已经存在于剪贴板中的东西粘贴到弹出式输入框中,我试过了:
import Html exposing (..)
import Html.App as Html
import Html.Events exposing (..)
import Html.Attributes exposing (..)
import Random
main : Program Never
main =
Html.program
{ init = init
, view = view
, update = update
, subscriptions = subscriptions
}
-- MODEL
type alias Model =
{ dieFaces : (List Int)
}
-- http://stackoverflow.com/questions/23199398/how-do-i-get-a-list-item-by-index-in-elm#comment56252508_23201661
get : Int -> List a -> Maybe a
get n xs = List.head (List.drop n xs)
-- http://rundis.github.io/blog/2016/elm_maybe.html
getOrOne : Int -> List Int -> Int
getOrOne n xs = Maybe.withDefault 1 (get n xs)
init : (Model, Cmd Msg)
init =
(Model [1, 1], Cmd.none)
-- UPDATE
type Msg
= Roll
| NewFace (List Int)
update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
case msg of
Roll ->
(model, Random.generate NewFace (Random.list 2 (Random.int 1 6)))
NewFace newFace ->
(Model newFace, Cmd.none)
-- SUBSCRIPTIONS
subscriptions : Model -> Sub Msg
subscriptions model =
Sub.none
-- VIEW
view : Model -> Html Msg
view model =
div []
[ img [ src ("/img/Alea_" ++ toString (getOrOne 0 model.dieFaces) ++ ".png")] []
, img [ src ("/img/Alea_" ++ toString (getOrOne 1 model.dieFaces) ++ ".png")] []
, button [ onClick Roll ] [ text "Roll" ]
]

也尝试过:
var clipboardData = window.clipboardData; //for IE
if (!clipboardData) { // for chrome
clipboardData = e.originalEvent.clipboardData;
}
window.prompt("PASTE to clipboard: Ctrl+V, Enter",clipboardData);