javascript在此特定页面中粘贴?

时间:2016-05-29 01:03:25

标签: javascript paste

这是一个具体情况: 访问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);



 以上两种方法都在" $(document).ready(function(){...}"结构中,因为我需要用它来点击那个橙色+按钮。 粘贴没有任何结果......我对javascript完全陌生。请问有什么想法吗?

0 个答案:

没有答案