How to redirect a page amp?











up vote
-1
down vote

favorite












I need to adapt the following javascript code to an amp page.



<select id="url"> 
<option value='home'>home</option>
<option value='contact'>contact</option>
</select>

<input type="button" value='ir' onclick='ir()'>

<script>
function ir(){
var url=document.getElementById("url").value;
location.href=url;
}
</script>


It's possible?



In the documentation I did not find the answer.










share|improve this question
























  • Welcome to Stack Overflow! Unfortunately, your problem is hard to understand as-is, and could use some clarification (what is "the thing")? What have you tried so far?
    – Jonathan Lam
    Apr 25 at 16:36










  • please move your comment code into the actual question. Not everyone reads comments as they are very difficult to parse without formatting.
    – Mozahler
    Apr 25 at 17:16















up vote
-1
down vote

favorite












I need to adapt the following javascript code to an amp page.



<select id="url"> 
<option value='home'>home</option>
<option value='contact'>contact</option>
</select>

<input type="button" value='ir' onclick='ir()'>

<script>
function ir(){
var url=document.getElementById("url").value;
location.href=url;
}
</script>


It's possible?



In the documentation I did not find the answer.










share|improve this question
























  • Welcome to Stack Overflow! Unfortunately, your problem is hard to understand as-is, and could use some clarification (what is "the thing")? What have you tried so far?
    – Jonathan Lam
    Apr 25 at 16:36










  • please move your comment code into the actual question. Not everyone reads comments as they are very difficult to parse without formatting.
    – Mozahler
    Apr 25 at 17:16













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I need to adapt the following javascript code to an amp page.



<select id="url"> 
<option value='home'>home</option>
<option value='contact'>contact</option>
</select>

<input type="button" value='ir' onclick='ir()'>

<script>
function ir(){
var url=document.getElementById("url").value;
location.href=url;
}
</script>


It's possible?



In the documentation I did not find the answer.










share|improve this question















I need to adapt the following javascript code to an amp page.



<select id="url"> 
<option value='home'>home</option>
<option value='contact'>contact</option>
</select>

<input type="button" value='ir' onclick='ir()'>

<script>
function ir(){
var url=document.getElementById("url").value;
location.href=url;
}
</script>


It's possible?



In the documentation I did not find the answer.







amp-html






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 9 at 11:23









Bachcha Singh

2,16721025




2,16721025










asked Apr 25 at 16:33









python

61




61












  • Welcome to Stack Overflow! Unfortunately, your problem is hard to understand as-is, and could use some clarification (what is "the thing")? What have you tried so far?
    – Jonathan Lam
    Apr 25 at 16:36










  • please move your comment code into the actual question. Not everyone reads comments as they are very difficult to parse without formatting.
    – Mozahler
    Apr 25 at 17:16


















  • Welcome to Stack Overflow! Unfortunately, your problem is hard to understand as-is, and could use some clarification (what is "the thing")? What have you tried so far?
    – Jonathan Lam
    Apr 25 at 16:36










  • please move your comment code into the actual question. Not everyone reads comments as they are very difficult to parse without formatting.
    – Mozahler
    Apr 25 at 17:16
















Welcome to Stack Overflow! Unfortunately, your problem is hard to understand as-is, and could use some clarification (what is "the thing")? What have you tried so far?
– Jonathan Lam
Apr 25 at 16:36




Welcome to Stack Overflow! Unfortunately, your problem is hard to understand as-is, and could use some clarification (what is "the thing")? What have you tried so far?
– Jonathan Lam
Apr 25 at 16:36












please move your comment code into the actual question. Not everyone reads comments as they are very difficult to parse without formatting.
– Mozahler
Apr 25 at 17:16




please move your comment code into the actual question. Not everyone reads comments as they are very difficult to parse without formatting.
– Mozahler
Apr 25 at 17:16












1 Answer
1






active

oldest

votes

















up vote
1
down vote













You are using button and onclick function, in place of this in AMP you can use anchor tag <a href="Value">Value</a> and change the url using `amp-bind'



You can use amp-bind to achieve your goal



Here is working URL



add JS in header



<script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>


Add code in body



<div class="wrapper">

<select on="change:AMP.setState({ url: event.value })">
<option value='home'>home</option>
<option value='contact'>contact</option>
</select>

<a [href]="url" href="home">ir</a>

</div>


Updated - if some one want to redirect on option change than use navigateTo action



Example :



<select on="change:AMP.navigateTo(url=event.value)">
<option value="http://google.com">google.com</option>
<option value="http://yahoo.com">yahoo.com</option>
<option value="http://bing.com">bing.com</option>
</select>





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50027232%2fhow-to-redirect-a-page-amp%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    You are using button and onclick function, in place of this in AMP you can use anchor tag <a href="Value">Value</a> and change the url using `amp-bind'



    You can use amp-bind to achieve your goal



    Here is working URL



    add JS in header



    <script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>


    Add code in body



    <div class="wrapper">

    <select on="change:AMP.setState({ url: event.value })">
    <option value='home'>home</option>
    <option value='contact'>contact</option>
    </select>

    <a [href]="url" href="home">ir</a>

    </div>


    Updated - if some one want to redirect on option change than use navigateTo action



    Example :



    <select on="change:AMP.navigateTo(url=event.value)">
    <option value="http://google.com">google.com</option>
    <option value="http://yahoo.com">yahoo.com</option>
    <option value="http://bing.com">bing.com</option>
    </select>





    share|improve this answer



























      up vote
      1
      down vote













      You are using button and onclick function, in place of this in AMP you can use anchor tag <a href="Value">Value</a> and change the url using `amp-bind'



      You can use amp-bind to achieve your goal



      Here is working URL



      add JS in header



      <script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>


      Add code in body



      <div class="wrapper">

      <select on="change:AMP.setState({ url: event.value })">
      <option value='home'>home</option>
      <option value='contact'>contact</option>
      </select>

      <a [href]="url" href="home">ir</a>

      </div>


      Updated - if some one want to redirect on option change than use navigateTo action



      Example :



      <select on="change:AMP.navigateTo(url=event.value)">
      <option value="http://google.com">google.com</option>
      <option value="http://yahoo.com">yahoo.com</option>
      <option value="http://bing.com">bing.com</option>
      </select>





      share|improve this answer

























        up vote
        1
        down vote










        up vote
        1
        down vote









        You are using button and onclick function, in place of this in AMP you can use anchor tag <a href="Value">Value</a> and change the url using `amp-bind'



        You can use amp-bind to achieve your goal



        Here is working URL



        add JS in header



        <script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>


        Add code in body



        <div class="wrapper">

        <select on="change:AMP.setState({ url: event.value })">
        <option value='home'>home</option>
        <option value='contact'>contact</option>
        </select>

        <a [href]="url" href="home">ir</a>

        </div>


        Updated - if some one want to redirect on option change than use navigateTo action



        Example :



        <select on="change:AMP.navigateTo(url=event.value)">
        <option value="http://google.com">google.com</option>
        <option value="http://yahoo.com">yahoo.com</option>
        <option value="http://bing.com">bing.com</option>
        </select>





        share|improve this answer














        You are using button and onclick function, in place of this in AMP you can use anchor tag <a href="Value">Value</a> and change the url using `amp-bind'



        You can use amp-bind to achieve your goal



        Here is working URL



        add JS in header



        <script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>


        Add code in body



        <div class="wrapper">

        <select on="change:AMP.setState({ url: event.value })">
        <option value='home'>home</option>
        <option value='contact'>contact</option>
        </select>

        <a [href]="url" href="home">ir</a>

        </div>


        Updated - if some one want to redirect on option change than use navigateTo action



        Example :



        <select on="change:AMP.navigateTo(url=event.value)">
        <option value="http://google.com">google.com</option>
        <option value="http://yahoo.com">yahoo.com</option>
        <option value="http://bing.com">bing.com</option>
        </select>






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 9 at 11:22

























        answered Apr 26 at 12:44









        Bachcha Singh

        2,16721025




        2,16721025






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50027232%2fhow-to-redirect-a-page-amp%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Hercules Kyvelos

            Tangent Lines Diagram Along Smooth Curve

            Yusuf al-Mu'taman ibn Hud