Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8839739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:18:22+00:00 2026-06-14T10:18:22+00:00

What I did: I created a index.html with a xss.js, which calls the jQuery.get()

  • 0

What I did:

I created a index.html with a xss.js, which calls the jQuery.get() function. Then I’ve opened the index.html in a browser (Firefox, Chrome, IE and Opera) and tried to trigger the ajax request.

The Code

Here is my index.html:

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>XSS</title>
        <script src="libs/js/jquery-1.7.2.js" ></script>
    </head>
    <body>
        <button id="request" >fire</button>
        <script src="libs/js/xss.js" ></script>
    </body>
</html>

and my xss.js:

function init()
{
    $('#request').click(loadContent);
}

function loadContent()
{
    $.get('http://www.example.com/', null, function(data){
        alert('success');            
        $('body').html(data);            
    }, 'html');

}

init();

If I open the index.html within a browser (file:///C:/workspace/xss%20test/index.html), I get the following responses after clicking the button:

  • Firefox: no error code (HTTP/1.1 200 OK), but the answer is empty

  • IE: no answer

  • Chrome:
    XMLHttpRequest cannot load http://www.example.com/. Origin null is not allowed by Access-Control-Allow-Origin.

  • Opera: no error code (HTTP/1.1 200 OK) and the complete html file as answer, but nothing will be displayed (the success callback is not being triggered)

This code will load the index.html into my Android WebView:

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        WebView webview = (WebView) findViewById(R.id.webview);

        webview.getSettings().setJavaScriptEnabled(true);
        webview.setWebChromeClient(new WebChromeClient());
        webview.setWebViewClient(new WebViewClient());

        webview.loadUrl("file:///android_asset/www/index.html");
    }
}

calls the success callback and also displays the content of www.example.com in the body of my index.html file, after the button is triggered.

(The same is possible on iPhone devices – I haven’t tested this on Windows Phone devices).

tl;dr – The Question:

Why is it possible to load content from a remote server to my mobile device – isn’t this a case of cross-domain scripting or am I missing something?

Due to browser security restrictions, most “Ajax” requests are subject to the same origin policy; the request can not successfully retrieve data from a different domain, subdomain, or protocol.

Also: Why does Opera receive an answer but does not display anything?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:18:23+00:00Added an answer on June 14, 2026 at 10:18 am

    Actually, your code fails on mobile browsers including ICS and Chrome on Android as well as Safari on iPhone. However, what you have shown is not loading the html file in a browser – it is loading it into a WebView – a different animal altogether.

    A WebView or Webkit is just a UI widget that implements browser-like functionality. They are not browsers. They do not provide stuff like the usual browser chrome and they have very liberal security models by default compared to browsers. Though, you can add code to implement things like same-origin-policy etc. if you want.

    It’s not only on mobile devices. Try creating a Webkit app on the desktop and you’ll see the same thing.

    I believe the reason for this is that WebViews and Webkits are assumed to be used to display content that you control 100%. Unlike browsers where users can enter any URL in the address bar. Therefore it’s up to you to vet weather the things you’re loading are safe or not.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created some tables using MySQL Workbench, and then did forward ‘forward engineer’ to
I created a project, probably as an Android project without thinking. I then did
My jQuery Mobile app consists of a single index.html page and contains only one
I have created a new branch and did svn import of the source files
Using storyboard ,I created a project. Inside viewDidLoad ,I did : NSLog(@"%@",self.view.description); I got
Theres a site i did that on the home page, i created kind of
I did this: [User.first, User.last].to_xml and got this: <users type=array> <user> <created-at type=datetime>2010-03-16T06:40:51Z</created-at> <id
info: xcode 4.3.2, iOS5, using storyboard. Created project from xcode's Tabbed Application template. Did:
I wanted to learn how to create python packages, so I visited http://docs.python.org/distutils/index.html .
Here how I created CKeditor in index.php(I am using it with CKfinder): < textarea

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.