开发者

Fetching external webpage to iframe [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 11 years ago.

I'm rather a noob to JavaScript and jQuery, so I need some help. WIthin my app, I've implemented a DatePicker calendar, loaded through an external js, and it works perfectly fine. I want to implement a jQuery button which can catch the date, i.e: 3rd of August, and fetch me a wikipedia page www.wikipedia.org/August_3. I also want this page to be uploaded to an iframe开发者_开发问答 below. How can I do that in jquery? Here are the simpliefied versions of the html and the js respectively.

<head>
    <script src=".../jquery.ui.button.js" type="text/javascript">
    <script src=".../jquery.ui.datepicker.js" type="text/javascript">
</head>
<body>
    <script src="/.../myscript.js" type="text/javascript">
    <div class="demo">
        <p>Date: <input id="datepicker" type="text"></p>
    </div>
    <script>
    $(document).ready(function()
    {
          $( "#datepicker" ).datepicker();
    });
    </script>


I'm rather a noob to javascript and jquery, so I need some help.

Starter

Mozilla JavaScript Guide

jQuery DOCs

jQuery tutorials

Advanced

Mozilla JavaScript DOCs

ECMA 5 DOCs

Douglas Crockford JavaScript

JavaScript best practices

Quirks Mode

Books

Recommended JavaScript books

Tools

JS Lint to check for bad written code

JS Fiddle to try out your scripts or piece of code

AVOID!

jQuery pitfalls to avoid

w3schools Check http://w3fools.com/

Personal advice

Remember jQuery is a library written in JavaScript, everything jQuery does can be done with plain JavaScript. Using a library such as jQuery is a good thing, because it will ensure cross-browser compatibility, has a large community, you need to write less code, and so on... but please don't abuse it. You can do simple tasks with JavaScript, avoiding useless function calls and slow scripts.


How can I do that in jquery?

Something like this:

$(document).ready(function()
{
    $( "#datepicker" ).datepicker()
        .bind(
            'dateSelected',
            function(e, selectedDate, $td)
            {
                Date.format = 'yyyymmdd';
                var dateStr = selectedDate.asString();
                $('#myIframe').attr('src', 'http://www.wikipedia.com/' + dateStr);
            }
    );
});

Read up on the DatePicker docs and this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜