0

I'm working on a feature that will make use of jquery, It works as expected, however I'm slightly confused as to why the jquery plugin source is being showed in my webpage..

Below is the code + html that is being used to generate the webpage

wbWinnersFeed.NavigateToString(
                Classes.FeedPage.GenerateFeed(data)

public static string GenerateFeed(List<Dictionary<string, string>> data)
{
    string rText = "<!DOCTYPE html><html><meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />";
    rText += "<head>";
    rText +=
        "<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js\"></script>" +
        "<script type=\"text/javascript\" src=\"https://gist.github.com/floatplane/6226786.js\"></script>";
    rText += "</head>";
    rText += "<body oncontextmenu='return false;' bgcolor='#252525';>";
    rText += "<style type='text/css'>body {overflow:hidden;}</style>";
    rText += "<font color=#7D7D7D>" +
             "<marquee behavior='scroll' direction='up' scrollamount='2' height='220px' width:'233px'>";

    int index = 0;
    foreach (var d in data)
    {
        foreach (var item in d)
        {
            rText += string.Format("{0} : {1}<br>", item.Key, item.Value);
        }
        if (index != data.Count - 1)
            rText += "<br>";
        index++;
    }
    rText += "</marquee></font></body></html>";
    return rText;
}

data = a list containing deserialized json

This works spot on and gives me a nice scrolling feed as expected.. with two odd side effects, the overflow is showing although it should be hidden by the style (not really an issue yet..), and the full github source is pulled into the document and shown on the webpage

Source Code and Body Style

Source Code and Body Style

How could I go about stopping the source code from being shown to the user? on the web page view (not inspect element, view source etc) (I'm not the strongest of html/js programmers)

I'm using a web browser control on wpf and I am navigating to the string that is created above.

Generated rText

<!DOCTYPE html><html><meta http-equiv='Content-Type' content='text/html; charset=UTF-8' /><head><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script><script type="text/javascript" src="https://gist.github.com/floatplane/6226786.js"></script></head><body oncontextmenu='return false;' bgcolor='#252525';><style type='text/css'>body {overflow:hidden;}</style><font color=#7D7D7D><marquee behavior='scroll' direction='up' scrollamount='2' height='220px' width:'233px'>NoData : No Data Has Been Loaded<br></marquee></font></body></html>
Andy
  • 823
  • 5
  • 17
  • 37
  • Provide the relevant code that can reproduce this problem. – wvdz Mar 01 '15 at 00:55
  • A few comments: `` tags don't admin closing `` tags. They also must appear in the `` section of your document. Don't use html tags or inline attributes instead of css (font, marquee etc.). Also, your font color should probably be quoted. Generally you should not generate the view from compiled code, except if you want to go back to c# the day you want to change the color of some text. If you generate a feed, you should use external html/css and fill it up with actual content (raw content) generated from c# – Sebas Mar 01 '15 at 01:27

1 Answers1

1

You're doing it wrong. The embed URL link on github that you used, is to display this code on a different site, for example, a blogpost that talks about the code.

If you want to use the actual code, you need to click "Raw" and save that file and put it on your server.

I guess you could also link directly to the github link like below, but I think that's not encouraged.

<script type="text/javascript" src="https://gist.githubusercontent.com/floatplane/6226786/raw/121626cdd9d49c808ab838f71803216b28d4552e/gistfile1.js"></script>
wvdz
  • 16,251
  • 4
  • 53
  • 90