Using angularjs variable inside iframe

前端 未结 2 667
心在旅途
心在旅途 2021-01-23 23:46

So I want to use a variable inside a iframe src or ng-src attribute. Apparently none of my variables get ever recognized, whatever I use. For example `



        
2条回答
  •  走了就别回头了
    2021-01-24 00:28

    You can set the src property with this syntax:

    iframeObject.src = URL

    To note: URL specifies the URL of the content to embed and it can be either an absolute or a relative URL.

    Example:

    document.getElementById('embedContent').src = "http://www.example.com";
    #embedContent{
            width: 600px;
            height: 500px;
        }

    Because you also want to concatenate / merge two strings, you can just change the JavaScript to

    document.getElementById('embedContent').src = "http://www.example.com/?name=" + test;
    

提交回复
热议问题